-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create API in Remote.Linq.EntityFrameworkCore to get query result without mapping to DynamicObject #130
Comments
Edit: |
Fluent API return await expression.EntityFrameworkCoreExecutor(efContext)
.With(PrepareRemoteLinqExpressionStrategy)
.With(PrepareSystemLinqExpressionStrategy)
.With(ProcessExecutionResultsStrategy)
.With(ProcessDynamicObjectResultsStrategy)
.ExecuteAsync(cancellation);
static Remote.Linq.Expressions.Expression PrepareRemoteLinqExpressionStrategy(Remote.Linq.Expressions.Expression exp)
=> exp;
static System.Linq.Expressions.Expression PrepareSystemLinqExpressionStrategy(System.Linq.Expressions.Expression exp)
=> exp;
static object ProcessExecutionResultsStrategy(object result)
=> result;
static DynamicObject ProcessDynamicObjectResultsStrategy(DynamicObject result)
=> result; Execution Decorator var executor = expression.EntityFrameworkCoreExecutor(efContext);
var decorator = new CustomExpressionExecutionDecorator(executor);
return await decorator.ExecuteAsync(cancellationToken); private sealed class CustomExpressionExecutionDecorator : AsyncExpressionExecutionContext<DynamicObject>
{
public CustomExpressionExecutionDecorator(AsyncExpressionExecutionContext<DynamicObject> parent)
: base(parent)
{
}
protected override Expression Prepare(Expression expression)
{
// used for synchronous and asynchronous execution
return base.Prepare(expression);
}
protected override System.Linq.Expressions.Expression Transform(Expression expression)
{
// used for synchronous and asynchronous execution
return base.Transform(expression);
}
protected override System.Linq.Expressions.Expression Prepare(System.Linq.Expressions.Expression expression)
{
// used for synchronous and asynchronous execution
return base.Prepare(expression);
}
protected override System.Linq.Expressions.Expression PrepareAsyncQuery(System.Linq.Expressions.Expression expression, CancellationToken cancellation)
{
// used for asynchronous execution only
return base.PrepareAsyncQuery(expression, cancellation);
}
protected override object Execute(System.Linq.Expressions.Expression expression)
{
// used for synchronous execution only
return base.Execute(expression);
}
protected override ValueTask<object> ExecuteAsync(System.Linq.Expressions.Expression expression, CancellationToken cancellation)
{
// used for asynchronous execution only
return base.ExecuteAsync(expression, cancellation);
}
protected override object ProcessResult(object queryResult)
{
// used for synchronous and asynchronous execution
return base.ProcessResult(queryResult);
}
protected override DynamicObject ConvertResult(object queryResult)
{
// used for synchronous and asynchronous execution
return base.ConvertResult(queryResult);
}
protected override DynamicObject ProcessConvertedResult(DynamicObject queryResult)
{
// used for synchronous and asynchronous execution
return base.ProcessConvertedResult(queryResult);
}
} |
Cool, thank s. It will resolve my case and more |
I am delighted with the capabilities of this library in conjunction with the Blazor web assembly. I have implemented data requests almost to the end. This mechanism should experimentally replace GraphQL with the exception of database modification operations. It remains for security purposes to get an IQueryable object associated with the DbContext for some restrictive manipulations (for example, the data output limit) |
Hello/ Thanks for great lib. Can you add API in
Remote.Linq.EntityFrameworkCore
to get query result without mapping toDynamicObject
?In my case i need to handle query result before send to a client. Now i have to convert dynamic object to an target object, and than convert it back to
DynamicObject
. I think its excess overhead.May be:
The text was updated successfully, but these errors were encountered: