This is a migrated thread and some comments may be shown as answers.

Linq to Open Access update multiple columns without assigning every column

1 Answer 47 Views
LINQ (LINQ specific questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ian Turvey
Top achievements
Rank 1
Ian Turvey asked on 09 Aug 2012, 10:41 AM

Hi is there a way to update multiple columns without assigning values from one object to another

product.Name = pro.Name;

If you have around 50 columns then it's quite annoying in Linq2Sql you can do something like this

 

 public Product UpdateRecord(Product pro)
{
      if (pro.ProductID > 0)       //means you have id so go for update
      {
         // get the existing record in a different method
           Product  PreviousRecord = Original_ByID(pro.ProductID);

           // Now time to change the existing record with new record passed in parameter
          var dal = new DALEntityModel();
          dal.Products.Attach(pro, PreviousRecord);
          dal.SubmitChanges();
      }
}

 public static Inventory Original_ByID(Int32 proId)
 {
       var dal = new DALEntityModel ();
       return (from p in dal.Products
                       where p.ProductId == proId
                       select p).Single();
  }

 

 

Is there a way to do this on open access

 

1 Answer, 1 is accepted

Sort by
0
Ivailo
Telerik team
answered on 14 Aug 2012, 10:25 AM
Hi Ian,

A similar functionality for attaching persistent entities is offered by OpenAccess ORM as well. You can find more details in the Attach/Detach functionality article.

I hope that helps. Let us know if you have any other questions.

Regards,
Ivailo
the Telerik team
Follow @OpenAccessORM Twitter channel to be the first one to get the latest updates on new releases, tips and tricks and sneak peeks at our product labs!
Tags
LINQ (LINQ specific questions)
Asked by
Ian Turvey
Top achievements
Rank 1
Answers by
Ivailo
Telerik team
Share this question
or