openaccess - Setting ID from related table in Telerik Open Access ORM -


i'm quite new using openaccess please bear me.

i have table called messages has column called messagetypeid, available ids in table called messagetypes, how can programmatically obtain id specific messagetype , assign new message object i'm creating.

there 2 possible solutions getting existing messagetype object associated new message 1 - please find them below:

1) associate them directly whole object using navigation property recommended approach - please find example below:

using (entitiesmodel db = new entitiesmodel()) {     message message = new message();     // existing messagetype database e.g. first 1 or     // db.messagetypes.first(mt => mt.name == "thenameyouarelookingfor");     messagetype messagetype = db.messagetypes.first();      message.messagetype = messagetype;      db.add(message);     db.savechanges(); } 

2) associate them using id of existing object below:

using (entitiesmodel db = new entitiesmodel()) {      message message = new message();     int messagetypeid = db.messagetypes.first().id;     message.messagetypeid = messagetypeid;      db.add(message);     db.savechanges(); } 

you find recommended approaches crud operations 1 have described @ the related documentation section.

in order more familiar telerik openaccess orm take @ getting started section , download openaccess orm samples kit containing lot of end-to-end sample applications both on c# , visual basic demonstrating integration different scenarios in n-tier applications , plenty of technologies asp.net, asp.net mvc, asp.net web api services, wcf services, wpf, silverlight, html5 , other examples recommended approaches crud operations, data streaming, working stored procedures , functions , many others.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -