代码之家  ›  专栏  ›  技术社区  ›  Matt

vs2010 linq to sql-从我的dbml添加实体

  •  1
  • Matt  · 技术社区  · 15 年前

    我想我可能要疯了…

    无论如何,我有一个dbml,其中有一个表'user'。很简单的东西-- 在一个班里,我有以下几项:

    BusinessDataContext businessDataContext = new BusinessDataContext();
    
    var user = new User();
    user.FirstName = FirstName;
    user.LastName = LastName;
    user.MiddleInitial = MiddleInitial;
    user.DateCreated = DateTime.UtcNow;
    
    /*
      There's no businessDataContext.User.Add method -- 
      There's a bunch of generic collection methods with the <> symbols 
      (Aggregate, All, Any...)
      Am I just too tired and missing something basic 
      or did something simple change with vs 2010?
    */
    
    businessDataContext.SubmitChanges();
    

    我想我真的需要睡觉。-)

    1 回复  |  直到 14 年前
        1
  •  2
  •   Marc Gravell    15 年前

    InsertOnSubmit ?即 businessDataContext.User.InsertOnSubmit(user); businessDataContext.Users.InsertOnSubmit(user); ?