private Sql.ExpressionAttribute GetDbFunctionFromMethodCall(Type type, MethodInfo methodInfo) { if (_dependencies == null || _model == null) { return(null); } methodInfo = (MethodInfo)type.GetMemberEx(methodInfo) ?? methodInfo; var found = _calculatedExtensions.GetOrAdd(methodInfo, mi => { EFCoreExpressionAttribute result = null; if (!methodInfo.IsGenericMethodDefinition && !mi.GetCustomAttributes <Sql.ExpressionAttribute>().Any()) { var value = Expression.Constant(DefaultValue.GetValue(type), type); var objExpr = new SqlTransparentExpression(value, _mappingSource?.FindMapping(type)); var parameterInfos = methodInfo.GetParameters(); var parametersArray = parameterInfos .Select(p => (SqlExpression) new SqlTransparentExpression( Expression.Constant(DefaultValue.GetValue(p.ParameterType), p.ParameterType), _mappingSource?.FindMapping(p.ParameterType))).ToArray(); var newExpression = _dependencies.MethodCallTranslatorProvider.Translate(_model, objExpr, methodInfo, parametersArray); if (newExpression != null) { if (!methodInfo.IsStatic) { parametersArray = new SqlExpression[] { objExpr } } .Concat(parametersArray).ToArray(); result = ConvertToExpressionAttribute(methodInfo, newExpression, parametersArray); }
protected bool Equals(SqlTransparentExpression other) { return ReferenceEquals(this, other); }