linq - How to change default behavior of .Where method in EntityFramework 4.1? -


i'd change default behavior of .where method specific case(s).

all business objects inherit baseobject has property int id {get; set;}

// base class public abstract class baseobject {     public abstract int id {get; set;} } 

i have 2 classes:

public partial class user : baseobject {     public override int id {get; set;}     public string username { get; set; }     public int profileid { get; set; }      public virtual profile profile { get; set; } }  public partial class profile : baseobject {     public override int id { get; set; }     public string name { get; set; }     public virtual icollection<user> users { get; set; }      public static profile getadminprofile()     {         return new profile(){id = 3, name = "admin profile"};     } } 

i write

// throws unable create constant value of type 'profile'... exception user admin = users.where(user.profile == profile.getadminprofile()).firstordefault(); 

instead of

user admin = users.where(user.profile.id == profile.getadminprofile().id).firstordefault(); 

is there way achieve this?

this known problem in entity framework. have follow second approach.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -