I'm not sure if this is possible in LINQ, but I have the following scenario:
I'm calling a SharePoint list service multiple times with multiple queries. I am then populating a single object and its properties from all of the queries. I am using LINQ to query the XElement returned. I know that if the call gets to this point, that there will only ever be one item returned from my LINQ query. I currently have to query into a new object and then set the properties of my main object from this new object (from LINQ), for each web service call. (The below code sample contains only a small portion of the 'Action' item properties that would need to be queried and set.)
Is there any way to make the below statement 'select' into my 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") as 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;