# HG changeset patch # User cin # Date 1408714486 -14400 # Node ID 1ef98bd704242d932764d0ab93d9347f6a8eae0e # Parent 79a04c6442bf9f238ee3455c93abfc17d0eae138 !bug 100 +3h Исправление проблемы BLToolkit + mono 3.4 diff -r 79a04c6442bf -r 1ef98bd70424 Source/Data/Linq/Builder/ExpressionBuilder.QueryBuilder.cs --- a/Source/Data/Linq/Builder/ExpressionBuilder.QueryBuilder.cs Fri Aug 22 13:41:57 2014 +0400 +++ b/Source/Data/Linq/Builder/ExpressionBuilder.QueryBuilder.cs Fri Aug 22 17:34:46 2014 +0400 @@ -324,7 +324,7 @@ { var pi = (MethodCallExpression)expr; var e = pi; - var l = SqlProvider.ConvertMember(e.Method); + var l = SqlProvider.ConvertMember(ReflectionHelper.ExtractMethodInfo(e)); if (l != null) return l.Body.Unwrap().Find(PreferServerSide) != null; diff -r 79a04c6442bf -r 1ef98bd70424 Source/Data/Linq/Builder/ExpressionBuilder.SqlBuilder.cs --- a/Source/Data/Linq/Builder/ExpressionBuilder.SqlBuilder.cs Fri Aug 22 13:41:57 2014 +0400 +++ b/Source/Data/Linq/Builder/ExpressionBuilder.SqlBuilder.cs Fri Aug 22 17:34:46 2014 +0400 @@ -425,7 +425,7 @@ Expression ConvertMethod(MethodCallExpression pi) { - var l = SqlProvider.ConvertMember(pi.Method); + var l = SqlProvider.ConvertMember(ReflectionHelper.ExtractMethodInfo(pi)); return l == null ? null : ConvertMethod(pi, l); } @@ -914,7 +914,7 @@ } else { - var l = SqlProvider.ConvertMember(e.Method); + var l = SqlProvider.ConvertMember(ReflectionHelper.ExtractMethodInfo(e)); if (l != null) return l.Body.Unwrap().Find(IsServerSideOnly) != null; diff -r 79a04c6442bf -r 1ef98bd70424 Source/Data/Linq/ReflectionHelper.cs --- a/Source/Data/Linq/ReflectionHelper.cs Fri Aug 22 13:41:57 2014 +0400 +++ b/Source/Data/Linq/ReflectionHelper.cs Fri Aug 22 17:34:46 2014 +0400 @@ -41,7 +41,13 @@ //if (ex is MemberExpression) // return ((PropertyInfo)((MemberExpression)ex).Member).GetGetMethod(); - return ((MethodCallExpression)ex).Method; + /// HACK + var mce = (MethodCallExpression)ex; + var mi = mce.Method; + if (mi.IsVirtual && mi.DeclaringType != mce.Object.Type) + mi = mce.Object.Type.GetMethod(mi.Name, mi.GetParameters().Select(p => p.ParameterType).ToArray()); + + return mi; } } @@ -54,10 +60,18 @@ return ex is MemberExpression ? ((MemberExpression) ex).Member : - ex is MethodCallExpression ? ((MethodCallExpression)ex).Method : + ex is MethodCallExpression ? ExtractMethodInfo((MethodCallExpression)ex) : (MemberInfo)((NewExpression) ex).Constructor; } + public static MethodInfo ExtractMethodInfo(MethodCallExpression mce) { + var mi = mce.Method; + if (mi.IsVirtual && mi.DeclaringType != mce.Object.Type) + mi = mce.Object.Type.GetMethod(mi.Name, mi.GetParameters().Select(p => p.ParameterType).ToArray()); + + return mi; + } + public class Binary : Expressor { public static MethodInfo Conversion = PropertyExpressor(e => e.Conversion);