c# - How to use LINQ to query from a list of objects into an existing object? -


i'm not sure if possible in linq, have following scenario:

i'm calling sharepoint list service multiple times multiple queries. populating single object , properties of queries. using linq query xelement returned. know if call gets point, there ever 1 item returned linq query. have query new object , set properties of main object new object (from linq), each web service call. (the below code sample contains small portion of 'action' item properties need queried , set.)

is there way make below statement 'select' existing 'action' object?

var item = (from listitem in result.getsplistitems()             select new contractaction             {                 title = listitem.getspfieldvalue("title"),                 description = listitem.getspfieldvalue("description"),                 deliveryorderid = sphelper.getfirstlookupid(listitem.getspfieldvalue("delivery order")),                 estimatedvalue = ((listitem.getspfieldvalue("estimated value") double?) ?? 0),                 agreementtypeid = sphelper.getfirstlookupid(listitem.getspfieldvalue("contract type")),                                                             }).firstordefault();  contractaction.title = item.title; contractaction.description = item.description; contractaction.deliveryorderid = item.deliveryorderid; contractaction.estimatedvalue = item.estimatedvalue; contractaction.agreementtypeid = item.agreementtypeid; 

can't simply:

action = (from listitem in result.getsplistitems()          select new action          {              title = listitem.getspfieldvalue("title"),              description = listitem.getspfieldvalue("description"),              deliveryorderid = sphelper.getfirstlookupid(listitem                  .getspfieldvalue("delivery order")),              estimatedvalue =                   ((listitem.getspfieldvalue("estimated value") double?) ?? 0),              agreementtypeid = sphelper.getfirstlookupid(listitem                  .getspfieldvalue("contract type")),          }).firstordefault(); 

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -