Hi, i'm having trouble creating a list based on data from a view. I can create the list with no issues, however when i attempt to filter the result (with a predicateexpression) i get errors.
The following code fails at the call to DataAccessAdapter.FetchTypedList with SqlException
The multi-part identifier "CRIExtract.dbo.vClaims.ClientId" could not be bound.
If line two (a filter against the clientid) is removed/commented-out the code runs fine.
I had a look at what was being generated and discovered that if I replace
[CRIExtract].[dbo].[vClaims].[ClientId] = @ClientId1
with
[vClaims].[ClientId] = @ClientId1
The sql executes successfully.
public DataTable LoadClaimReport(int entityId, string groupBy)
{
RelationPredicateBucket filter = new RelationPredicateBucket();
filter.PredicateExpression.Add(VClaimsFields.ClientId == entityId);
VClaimsFieldIndex fieldEnum = (VClaimsFieldIndex)Enum.Parse(typeof(VClaimsFieldIndex), groupBy);
EntityField2 groupByField = (EntityField2)EntityFieldFactory.Create(fieldEnum);
ResultsetFields fields = new ResultsetFields(3);
//fields.DefineField(VClaimsFields.ClientId, 0, "ClientId", "vClaims");
fields.DefineField(VClaimsFields.Period, 0, "Period", "vClaims");
fields.DefineField(groupByField, 1, groupBy, "vClaims");
fields.DefineField(VClaimsFields.Incurred, 2, "IncurredSum", "vClaims", AggregateFunction.Sum);
IGroupByCollection groupByClause = new GroupByCollection();
groupByClause.Add(fields[0]);
groupByClause.Add(fields[1]);
SortExpression exp = new SortExpression(VClaimsFields.Period | SortOperator.Descending);
DataTable tlist = new DataTable();
DataAccessAdapter adapter = new DataAccessAdapter();
adapter.FetchTypedList(fields, tlist, filter, 0, exp, true, groupByClause);
adapter.CloseConnection();
return tlist;
}
What am I doing wrong? All the examples in the docs seem to add a relationship object in to the Relations collection of the PredicateBucket. I dont have any relations to add though...