score:1

Accepted answer
//just grab the first item
var item = result.getsplistitems().firstordefault();

//then grab the properties into the existing contractactionentity                             
contractaction.title = item.getspfieldvalue("title");
contractaction.description = item.getspfieldvalue("description");
contractaction.deliveryorderid = sphelper.getfirstlookupid(item.getspfieldvalue("delivery order"));
contractaction.estimatedvalue = item.getspfieldvalue("estimated value").tonullabledouble();
contractaction.agreementtypeid = sphelper.getfirstlookupid(item.getspfieldvalue("contract type")),

score:0

var item = (from listitem in result.getsplistitems()
        from query2outer in result.secondquery().where(x => x.itemedp == it.itemedp).defaultifempty() // this is an outer join
        select new action
        {
            //if the one query didn't return an item then it sets the properties to the default values
            example = (query2outer == null ? "default value" : query2outer.example),
            title = listitem.getspfieldvalue("title"),
            description = listitem.getspfieldvalue("description"),
            deliveryorderid = sphelper.getfirstlookupid(listitem.getspfieldvalue("delivery order")),
            estimatedvalue = ((listitem.getspfieldvalue("estimated value") as double?) ?? 0),
            agreementtypeid = sphelper.getfirstlookupid(listitem.getspfieldvalue("contract type")),                                                
        }).firstordefault();

score:0

contractaction targetaction = new contractaction();
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") as double?) ?? 0),
                agreementtypeid = sphelper.getfirstlookupid(listitem.getspfieldvalue("contract type")),                                                
            }).selectfirstinto(targetaction);

score:1

public static myaction tomyaction(this splistitem item)
{
    return new myaction  
       {  
          title = item.getspfieldvalue("title"),  
          description = item.getspfieldvalue("description"),  
          deliveryorderid = sphelper.getfirstlookupid(item.getspfieldvalue("delivery order")),  
          estimatedvalue = ((item.getspfieldvalue("estimated value") as double?) ?? 0),  
          agreementtypeid = sphelper.getfirstlookupid(item.getspfieldvalue("contract type"))                                                  
       };  
}

var action = result.getsplistitems()
                   .select(item => item.tomyaction())
                   .firstordefault();
//var action = (from item in result.getsplistitems()
//              select item.tomyaction()).firstordefault();

score:2

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") as double?) ?? 0),
             agreementtypeid = sphelper.getfirstlookupid(listitem
                 .getspfieldvalue("contract type")),
         }).firstordefault();

Related Query

More Query from same tag