none
Entity framework updating the table with the list of object in the list and get the result of updated rows. RRS feed

  • Question

  • Hi I am trying to write an entity query from linq to sql. 

    Iwant to update the fields of by referencing the object in request which is a list.  

    When i am updating . I want to get the field id back upon successful update so I can do some work with response object. 

                         

    private UpdateAsync(UpdateRequest request)

            {
                var UpdateResponse = new UpdateResponse();

                var Ids = request.OrderForUpdate.Select(a => a._ID);  //OrderForUpdate is a list. 

                // var selected = table.Where(t => uids.Contains(t.uid));
                var AccessRequest = Message.ExtractDatabaseAccessRequest(request.Header); //connection info
                var memberContext = new dataContext(AccessRequest);

                var getRecordsToUpdate = dataContext.tbOrder.Where(a => id.Contains(a.ID)).ToList();

                foreach (var r in getRecordsToUpdate)
                {
                    r.item= request.OrderUpdate.First().item;}

       // I want to get the updated list so I can create return object based on the values return.          }

            }


    i am a novice and a student

    Saturday, January 21, 2017 12:20 AM

Answers