예제 #1
0
    public Order Update(UserBusiness obj)
    {
        UserDAL u = new UserDAL();

        u.Id              = obj.Id;
        u.Name            = obj.Name;
        db.Entry(u).State = EntityState.Modified;
        db.SaveChanges();
        return(obj);
    }
 public void UpdateMaster(Master master)
 {
     using (var context = new YourContext())
     {
         context.Master.Attach(master);
         context.Entry(master).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
    public void DeleteBook(Book book)
    {
        // assuming that you're working on context directly and need to dispose it
        using (var context = new YourContext())
        {
            var entry = context.Entry(book);
            // Will tell you if Author navigation property is loaded
            bool isLoaded = entry.Reference(x => x.Author).IsLoaded();

            if (isLoaded != false)
            {
                // do when Author navigation property is loaded
            }
            else
            {
                // do when Author navigation property is not loaded
            }
        }
    }