3
それはGETリクエスト変更MethodCallExpression引数(C#LINQ)
のために実行される前に、これは、ODataのは、すべての従業員をロードするための要求をGETです:
私が持っているserver/employees?$filter=birthday+ge+datetime'1985-01-01'
// My class inherits from IQToolkit which is building an expression based on the request
public class MyQueryProvider : QueryProvider
{
// Is defined in advance (after a client established a connection)
private int clientDepartmentNo;
// This is the central function, which gets a MethodCallExpression from the toolkit
// and executes it
public override object Execute(MethodCallExpression expression)
{
// The current content of expression (see my OData URL above):
// "value(NHibernate.Linq.NhQueryable`1[Models.Employee]).Where(it => (it.Birthday >= Convert(01.01.1985 00:00:00)))"
// Now I would like to extend the expression like that:
// "value(NHibernate.Linq.NhQueryable`1[Models.Employee]).Where(it => (it.Birthday >= Convert(01.01.1985 00:00:00)) && it.DepartmentNo == clientDepartmentNo)"
// That works fine
var additionalExpressionArgument = (Expression<Func<Employee, bool>>)(x => x.DepartmentNo == clientDepartmentNo);
// But that is still not possible, because the property .Arguments is readonly...
expression.Arguments.Add(additionalExpressionArgument);
// Can you give me an advice for a working solution?
// Would like to execute the query based on the URL and extension
return nHibernateQueryProvider.Execute(expression);
}
}
は、私は上記のexpression.Arguments.Add
の代わりに何をする必要があります。次のコードを使用してみましたか?あなたのQueryProvider
を推測