What you are doing now will work just fine If you would like to avoid doing a database query when assigning ode. Products, then you could use the following alternative: substitute your actual qualified entity set name ode. ProductsReference.
EntityKey = new EntityKey("MyEntities. ProductsEntitySetName", "Id", 2) This is faster, but less readable. Also, the Products property will be null until you Load it.
But for an insert, this is often OK.
What you are doing now will work just fine. If you would like to avoid doing a database query when assigning ode. Products, then you could use the following alternative: // substitute your actual qualified entity set name ode.
ProductsReference. EntityKey = new EntityKey("MyEntities. ProductsEntitySetName", "Id", 2); This is faster, but less readable.
Also, the Products property will be null until you Load it. But for an insert, this is often OK.
– Binoj Antony Jul 21 '09 at 13:51 I'm not sure what you mean. What kind of shortcuts are you expecting? Can you be more specific about your needs?
– Craig Stuntz Jul 21 '09 at 13:58 I wanted to know how I would do the exact same action done above but for an update operation. – Binoj Antony Jul 21 '09 at 14:05 Because it looks like I need to again do the query from the db to get the entities then change the property (to change the enityState) then do the update(SaveChanges), any simpler/easier way? – Binoj Antony Jul 21 '09 at 14:11 That is right.
For an update you must first select, then save. – Craig Stuntz Jul 21 '09 at 16:42.
Another approach would be to use Stub Objects rather than EntityKeys i.e. Var product = new Product {ID = 2}; ctx. AttachTo("Products", product); ode.
Product = product; etc. As an added bonus this code will work with POCO objects too in the future. See this blog post for more information on that technique.
I tried this first and found that when calling ctx.SaveChanges() it tries to insert even the Products – Binoj Antony Jul 22 '09 at 5:46.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.