-1

I'm using a repository for my models like this

public IEnumerable<object> GetDetailList(int userId, int page, int rp, string sortname, string sortorder, ref int num, ref int numpg)
{
    var details = (from access in context.erp_sec_companyaccesses
                   join company in context.erp_maint_companies on Convert.ToInt32(access.company_id) equals company.company_id
                   where access.user_id == userId
                   select new
                   {
                       pkey = access.company_access_id,
                       company_access_id = access.company_access_id,
                       company_code = company.company_code,
                       company_name = company.company_name,
                       company_id = company.company_id
                   });

    num = details.Count();
    numpg = (int)Math.Ceiling((float)(num / rp));

    details = details.OrderBy(sortname+" "+sortorder).Skip(page * rp).Take(rp);

    return details;
}

But I'm struggling to upcast the IEnumerable<object> returned to the controller. Is there any alternative than this ?

Update : I give up up-casting, I'll send a typed object instead of anonymous, thanks everybody


First you need to understand working of .apk and .odex file.

.Odex file:
Odex file is the extracted and optimized DEX file (classes.dex) from APK or JAR files.
An ODEX file has dependencies on every file in the BOOTCLASSPATH that is loaded when it is generated.
The odex file is only valid when used with these exact BOOTCLASSPATH files.
Android Application come in packages with the extension .apk. These application packages, or APKs contain certain .odex files whose supposed function is to save space.
These ‘odex’ files are actually collections of parts of an application that are optimized before booting.
It also makes hacking those applications difficult because a part of the coding has already been extracted to another location before execution.

How it work:-
Android OS uses a Java-based virtual machine for running applications, called the Dalvik Virtual Machine. A deodexed, or .dex file contains the cache used by this virtual machine (referred to as Dalvik-cache) for a program, and it is stored inside the APK. An .odex file, on the other hand, is an optimized version of this same .dex file that is stored next to the APK as opposed to inside it.
Android applies this technique by default to all the system applications.

Now, when an Android-based system is booting, the davlik cache for the Davlik VM is built using these .odex files, allowing the OS to learn in advance what applications will be loaded, and thus speeds up the booting process.

By deodexing these APKs, a developer actually puts the .odex files back inside their respective APK packages. Since all code is now contained within the APK itself, it becomes possible to modify any application package without conflicting with the operating system’s execution environment.

You can find some information Here and
Here is one StackOverFlow question may helpful to you.

4

3 回答 3

0

您不应该传递匿名对象。我昨天尝试过这样做,但没有找到简单的解决方案。所以最好的办法是为你的数据创建另一个类。

这是 Skeet 的答案:为什么匿名类型不能在方法周围传递?

于 2012-09-14T09:16:30.590 回答
0

我猜您可能想要创建一个具体类型,例如Details并从您的函数返回一个IEnumerable<Details>而不是一个IEnumerable<object>.

我假设这是因为看起来您可能想要访问在代码中其他地方的函数内创建的匿名类型的字段。

于 2012-09-14T09:16:44.810 回答
0

为什么不使用泛型并将您想要的对象类型传递给您的方法并返回它呢?

于 2012-09-14T09:25:20.540 回答