开发者

In Entity Framework, what is the parent type of all ObjectQuery fields?

开发者 https://www.devze.com 2023-01-23 09:24 出处:网络
I need to OrderBy( p => new SomeClass {p.firstField, p.secondField} ) where public class SomeClass<T>

I need to

OrderBy( p => new SomeClass {p.firstField, p.secondField} )

where

public class SomeClass<T>
{    T firstField {get;set;}
     T secondField {get;set;}
}

What is the most specific Entity Framework 4 type that T can be?

What code could I use to set firstFi开发者_如何学运维eld's and secondField's value?

(meaning I want firstField to reference p.ID and secondField to reference p.Name).


The type of the fields are the normal .NET types. This means that when firstField references to ID, this will probably be an int or a Guid and secondField will probably be a string.

If you are creating a generic class to do ordering with, this is not necessary. You can also do this:

OrderBy( p => new { p.ID, p.Name } )

This will automatically create a type for you.

0

精彩评论

暂无评论...
验证码 换一张
取 消