开发者

How add entity from table many to many

开发者 https://www.devze.com 2023-03-12 08:02 出处:网络
Create entity Desk: var desk = new Desk() { x = Convert.ToInt32(Canvas.GetLeft(item)), y = Convert.ToInt32(Canvas.GetTop(item)),

Create entity Desk:

var desk = new Desk()
           {
           x = Convert.ToInt32(Canvas.GetLeft(item)),
           y = Convert.ToInt32(Canvas.GetTop(item)),
           width = item.Width,
           height = item.Height,
           };

Add to table Desks:

m_RoomsContext.Desks.Add(desk);

And I need add desk.id and other id_room, but desk.id == 0.

m_RoomsContext.RoomToStandartDesks.Add(new RoomT开发者_StackOverflow社区oStandartDesk()
                       {
                           id_room = int.Parse(btnSave.Tag.ToString()),
                           id_desk = desk.id
                       }
                       );

How update desk ? or how to do it?


I think you're looking to update the changes to entities? If so:

m_RoomsContext.SaveChanges();
0

精彩评论

暂无评论...
验证码 换一张
取 消