We have a table that looks almost like this:
create table lockers { UserID int null primary key (foreign key), locker stylized int (foreign key), nameplate id int (foreign key)} all keys are related to other tables, but the way the application is distributed It is easy for us to pass along the ID as a parameter, so we want to do this: Locker l = New Locker {UserID = userID, LockerSistilID = Locker Stylid, Nameplate ID = Nameplate ID}; Entities.AddLocker (L);
We can do this in LINQ-to-SQL, but not EF?
This missing feature starts to bother a lot of people
- Good news: MS will address this problem with .NET 4.0.
- Bad news: for now, or if you're stuck at 3.5 then you have to do something a bit of work, but this is possible.
You have to do this:
locker locker = new locker (); Locker User Reference. Antitiki = new system Data Antiquity ("Institutions.", "ID", UserID); Locker Lockerstyle Reference. Antitiki = New Unit Key ("Institutions. Locker Style", "ID", Locker Style); Locker .Name Reference References. Antiquity = New Entity ("Institutions. Name Table", "ID", Nameplate ID); Entities.AddLocker (Locker); Entities.SaveChanges ();
Comments
Post a Comment