I have the following enumeration Extension method:
public static Expression<Func<Table, object>> GetGroupByClause(this OntDubbelingsEigenschappen o)
{
switch (o)
{
case OntDubbelingsEigenschappen.Voornaam:
return w => w.TableField1;
case OntDubbelingsEigenschappen.Achternaam:
return w => w.TableField2;
case OntDubbelingsEigenschappen.Emailadres:
return w => w.TableField3;
case OntDubbelingsEigenschappen.GeboorteDatum:
return w => w.TableField4;
default:
return null;
}
}
Now I want to use this extension to create the following query:
List<Expression<Func<Table, object>>> delList = new List<Expression<Func<Table, object>>>();
ontdubbelEigenschapIds.ForEach(f => delList.Add(f.GetGroupByClause()));
var users = Db.Table.GroupBy(x => new { delList })
.SelectMany(s => s).ToList().Select(s =>
new Model(s, isOverTakeActive)).ToList();
This does not work, because I am passing a non-primitive type along in the query. How can I do this in a correct way?