views:

19

answers:

1

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 firstField's and secondField's value?
(meaning I want firstField to reference p.ID and secondField to reference p.Name).

A: 

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.

Pieter