Здравствуйте!
Возможно, что-то не то делаю, тогда поправьте.
Просто запускаю тест из статьи
Linq-провайдер для BLToolkit (предварительно вставив свежий BLToolkit.4.dll и переделав проект в .NET Framework 4):
И спотыкается на BLToolkit.Data.Linq.Builder.SelectContext.BuildQuery<T>(...):
public virtual void BuildQuery<T>(Query<T> query, ParameterExpression queryParameter)
{
var expr = BuildExpression(null, 0);
var mapper = Expression.Lambda<Func<QueryContext,IDataContext,IDataReader,Expression,object[],T>>(
Builder.BuildBlock(expr), new []
{
ExpressionBuilder.ContextParam,
ExpressionBuilder.DataContextParam,
ExpressionBuilder.DataReaderParam,
ExpressionBuilder.ExpressionParam,
ExpressionBuilder.ParametersParam,
});
query.SetQuery(mapper.Compile());
}
System.ArgumentException was unhandled
Message=Expression of type 'Linq.Demo.DataModel.Northwind+Product' cannot be used for return type 'Linq.Demo.DataModel.Northwind+DiscontinuedProduct'
Source=System.Core
StackTrace:
at System.Linq.Expressions.Expression.ValidateLambdaArgs(Type delegateType, Expression& body, ReadOnlyCollection`1 parameters)
at System.Linq.Expressions.Expression.Lambda[TDelegate](Expression body, String name, Boolean tailCall, IEnumerable`1 parameters)
at System.Linq.Expressions.Expression.Lambda[TDelegate](Expression body, Boolean tailCall, IEnumerable`1 parameters)
at BLToolkit.Data.Linq.Builder.SelectContext.BuildQuery[T](Query`1 query, ParameterExpression queryParameter) in P:\C#\Libs\BLToolkit\github.com\current\Source\Data\Linq\Builder\SelectContext.cs:line 64
at BLToolkit.Data.Linq.Builder.ExpressionBuilder.Build[T]() in P:\C#\Libs\BLToolkit\github.com\current\Source\Data\Linq\Builder\ExpressionBuilder.cs:line 165
at BLToolkit.Data.Linq.Query`1.GetQuery(IDataContextInfo dataContextInfo, Expression expr) in P:\C#\Libs\BLToolkit\github.com\current\Source\Data\Linq\Query.cs:line 134
at BLToolkit.Data.Linq.Table`1.GetQuery(Expression expression, Boolean cache) in P:\C#\Libs\BLToolkit\github.com\current\Source\Data\Linq\TableT.cs:line 106
at BLToolkit.Data.Linq.Table`1.Execute(IDataContextInfo dataContextInfo, Expression expression) in P:\C#\Libs\BLToolkit\github.com\current\Source\Data\Linq\TableT.cs:line 98
at BLToolkit.Data.Linq.Table`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator() in P:\C#\Libs\BLToolkit\github.com\current\Source\Data\Linq\TableT.cs:line 193
at Linq.Demo.Program.InheritanceTest1() in P:\C#\Libs\BLToolkit\temp_test\LinqWithBLToolkit\Program.cs:line 284
at Linq.Demo.Program.Main() in P:\C#\Libs\BLToolkit\temp_test\LinqWithBLToolkit\Program.cs:line 31
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()