Environment:
C# ASP.NET 3.5
LLBLGen v3.1.0.0
I'm attempting to dynamically set up the list of fields to include when fetching data. I'm using adapter and LLBLGen Linq libraries.
I'm attempting to do it through the Fields collection on an Entity, but I get an error back when I try to use it:
The property 'Fields' isn't mapped to a field or database construct of entity type 'LoanEntity'. Did you mean to call an extension method instead? ('Count' vs. 'Count()') ?
Code:
public static List<LoanEntity> ProcessLoanQuery(List<SelectField> fields, List<SearchItem> searchItems)
{
using (DataAccessAdapter da = GetAdapter())
{
LinqMetaData md = new LinqMetaData(da);
var q = (
from l in md.Loan
select l
);
// TODO - figure out how to dynamically apply .IncludeFields
LoanEntity empty = new LoanEntity();
foreach (SelectField field in fields)
{
// doesn't work
//q = q.IncludeFields<LoanEntity>(f => f.Fields[field.Field]);
// also doesn't work
int index = empty.Fields[field.Field].FieldIndex;
q = q.IncludeFields<LoanEntity>(f => f.Fields[index]);
}
SearchProcessor.ApplySearchCriteria<LoanEntity>(ref q, searchItems);
return (q as ILLBLGenProQuery).Execute<EntityCollection<LoanEntity>>().ToList();
}
}
Anyone have any thoughts / examples on how I might accomplish this?
Thanks in advanced.