Many2Many relations handling

May 23, 2012 at 1:17 PM

Hi!

I'm learning from this project and folowing practises in mine personal project,

So thx a lot and don't stop ;)

But, I have stucked with inserting and updating entity object wich have many2may relation thru command object.

What would be best practise for that kind of situation?

 

Thanks ahead

Jun 3, 2012 at 7:29 PM

Interested in this as well!

Jun 12, 2012 at 5:53 AM

insert like this:

using (var db = new ExampleEFEntities())

{

var m = new Members() { Age = 123, Email = "123@mail.com", Name = "321", PassWord = "123" };

var g1 = new Goods() { GoodsName = "Computer", GoodsPrice = 3210 };

var g2 = new Goods() { GoodsName = "Mobile", GoodsPrice = 1230 };

m.Goods.Add(g1);

m.Goods.Add(g2);

db.Members.AddObject(m);

db.SaveChanges();

}