开发者

How can I select a specific entity object for update?

I'm pulling all the objects from an entity in my database

Dim dbConfig as New housingEntities
Dim update_query = (From p in dbConfig.Configs _
                    Select p)

Then, I want to individually access the rows and perform updates to them...For example, if I just needed the first row I could go like this:

update_query.First.timeValue = txtFRRSD.Text
dbConfig.SubmitChanges()

Now, I don't know how to code this, but here is pseudo what I'd like to do:

update_query.Item("FRRSD").timeValue = txtFRRSD.Text
update_query.Item("FRRCD").timeValue = txtFRRCD.Text
update_query.Item("SORSD")开发者_开发百科.timeValue = txtSORSD.Text
update_query.Item("SORCD").timeValue = txtSORCD.Text
dbConfig.SubmitChanges()

Does anyone know a way to do this or something like this?


Here is a generic example in C# of how I would update many entity objects at once.

public void UpdateWidgetEntities(List<WidgetEntity> newWidgets)
{
   WidgetEntities widgetDB = new WidgetEntities();
   var dbWidgets = (from w in widgetDB.WidgetTable
                   where newWidgets.Contains(w.WidgetID)
                select w).ToList();

   foreach(var dbWidget in dbWidgets)
   {
      foreach(var widget in newWidgets)
      {
         if(dbWidget.WidgetID = widget.WidgetID)
            dbWidget.WidgetValue = widget.WidgetValue;
      }
   }
   widgetDB.SaveChanges();

}

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜