entity framework - ObjectContext.CreateObject<T>: Create ComplexObject -


could please explain following:

i have following code creates instance of type specified:

methodinfo methodinfo = this._dbcontext.gettype().getmethod("createobject").makegenericmethod(instancetype); object invokedobject = methodinfo.invoke(this._dbcontext, null); 

where _dbcontext in entity model.

when try create instance of following class happy , works:

public partial class user : entityobject {  .... } 

but when try same within following class - receive error:

the member identity 'mynamespace.account' not exist in metadata collection.

public partial class account : complexobject { .... } 

could please explain why i'm able create instance / object of entityobject not complexobject ?

many thanks!!

[update]

    public objectset<user> users     {                 {             if ((_users == null))             {                 _users = base.createobjectset<user>("users");             }             return _users;         }     }     private objectset<user> _users; 

there 2 problems:

  1. as noted in updated question, context doesn't contain reference account, need add before requesting (using 'createobject' method) context:

    public objectset<account> accounts {         {         if ((_accounts == null))         {             _accounts = base.createobjectset<account>("accounts");         }         return _accounts;     } }  private objectset<account> _accounts; 
  2. since account complextype don't think you'll able use objectset<>, since complextype not have identity , can used part of parent entity.


Comments

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -