How to use the result of this LINQ in another method and get the properties CountryID
and count
?
public IQueryable GetRequestsByRegion(string RequestType)
{
try
{
var q = from re in context.RequestExtensions
from r in context.Requests
where re.ExtensionID == r.ExtraInfoID
&& r.OriginalRequestID == null
&& r.RequestType == RequestType
group re by new { CountryID = re.CountryID } into grouped
select new { CountryID = (int)grouped.Key.CountryID, count = (int)grouped.Count(t => t.CountryID != null) } ;
return q;
}
catch (Exception ex)
{
}
return null;
}
public void GetAllInformationRequestsByRegion()
{
IQueryable dict = GetRequestsByRegion("tab8elem1");
/* How to iterate and get the properties here? */
}
The return types and variable types don't need to be the ones indicated... This was just my try. I am also using WCF so I can't return Object types.
Just like as if it were any other kind of object:
foreach(var obj in q) {
var id = obj.CountryID;
var count = obj.count;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With