I am working in a C# 2010 application where I have written the following lines of linq to sql code:
int TotCount = 0;
string[] PkgIDs = rptData.Transaction.Where(c =>c.Package_ID.StartsWith("rva") &&
c.Received_Date != null ).Select(c => c.Package_ID).ToArray();
foreach (string PkgID in PkgIDs)
{
var eCnt = rptData.Details.Where(c =>c.Package_ID == PkgID).Select(c =>c.TotalTrans);
TotCount = Convert.ToInt32(eCnt);
}
My problem line of code is: var eCnt = rptData.Details.Where(c =>c.Package_ID == PkgID).Select(c =>c.TotalTrans);
I want to be able to obtain the value contained in the c.TotalTrans field and place the value in the eCnt field.
When I am stepping through the code and go to the line right after the line I listed above, I only see the sql equivalent value. I want to see the value for c.TotalTrans in the eCnt field.
I know what I need now is to actually make the linq to sql statement actually execute. That would be similar to the 'ToArray()'
statement listed above. However, I do not know what to change in the statement to actually obtain the value.
Thus can you tell me what else I need to add to this statement so that I get my desired result?
Loading
VulpesPosted Sep 21, 2012, 6:29 PM
They need to be there as it's a method rather than a property.
Chiranjita NayakPosted Sep 26, 2012, 3:18 AM
Sie StePosted Sep 21, 2012, 6:01 PM
"Error 1 Cannot assign method group to an implicitly-typed local variable ".
Thus can you tell me what else to try with this statement and/or how to rewrite the linq to sql statement to get the results I am looking for?
VulpesPosted Sep 21, 2012, 5:26 PM