I'm using Linq2db with a custom server-side only function:
[Sql.Function(Name = "UniqueValue", ServerSideOnly = true)]
public static int? UniqueValue( Expression<Func<ModelClass, string>> arg) {
throw new NotSupportedException();
}
I then try to use it in a linq query with grouping:
var query = from a in context.data
group a by a.field1 into newgroup
select new {final = UniqueValue(row => row.field2) };
I then get "row => row.field2' cannot be converted to SQL." error at runtime.
I'm using SqlLite as the db, here is the the custom function:
[SQLiteFunction(Name = "UniqueValue", Arguments = 1, FuncType = FunctionType.Aggregate)]
public class UniqueValue : SQLiteFunction {
public override void Step(object[] args, int stepNumber, ref object contextData) {
}
public override object Final(object contextData) {
return null;
}
}
Does anyone know how I can make a custom server-side only function work with grouping?