You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

NpgsqlStoredProcTranslator.cs 812B

1234567891011121314151617181920212223
  1. using System;
  2. using System.Linq.Expressions;
  3. using System.Reflection;
  4. using Microsoft.EntityFrameworkCore;
  5. using Microsoft.EntityFrameworkCore.Query.Expressions;
  6. using Microsoft.EntityFrameworkCore.Query.ExpressionTranslators;
  7. namespace Luticate2.Utils.DataAccess.Npgsql
  8. {
  9. public class NpgsqlStoredProcTranslator : IMethodCallTranslator
  10. {
  11. private readonly Type _declaringType = typeof(DbContext);
  12. public Expression Translate(MethodCallExpression methodCallExpression)
  13. {
  14. if (_declaringType.IsAssignableFrom(methodCallExpression.Method.DeclaringType))
  15. {
  16. return new SqlFunctionExpression(methodCallExpression.Method.Name, methodCallExpression.Type, methodCallExpression.Arguments);
  17. }
  18. return null;
  19. }
  20. }
  21. }