I have case in my code where I use VirtualQueryableCollectionView bind to RadGridView. I want to after VirtualQueryableCollectionView load records from query map to other objects. Something like that:
This will allow me to bind to WorkViewModel which contains extra logic. But constructor throws exception:
Are there any possibilities to force VirtualQueryableCollectionView to map loaded objects to other objects.
using
(var workRepo =
new
WorkRepository())
{
IQueryable<WorkViewModel> works = workRepo.All<Work>().OrderBy(
"Title"
).Select(work =>
new
WorkViewModel(work));
virtualCollection =
new
VirtualQueryableCollectionView(works) { LoadSize = 50 };
}
This will allow me to bind to WorkViewModel which contains extra logic. But constructor throws exception:
System.NotSupportedException was caught
HResult=-2146233067
Message=Only parameterless constructors and initializers are supported
in
LINQ to Entities.
Source=EntityFramework
StackTrace:
w System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.NewTranslator.TypedTranslate(ExpressionConverter parent, NewExpression linq)
w System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.TypedTranslator`1.Translate(ExpressionConverter parent, Expression linq)
w System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.TranslateExpression(Expression linq)
w System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.TranslateLambda(LambdaExpression lambda, DbExpression input)
w System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.TranslateLambda(LambdaExpression lambda, DbExpression input, DbExpressionBinding& binding)
w System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.MethodCallTranslator.OneLambdaTranslator.Translate(ExpressionConverter parent, MethodCallExpression call, DbExpression& source, DbExpressionBinding& sourceBinding, DbExpression& lambda)
w System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.MethodCallTranslator.SelectTranslator.Translate(ExpressionConverter parent, MethodCallExpression call)
w System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.MethodCallTranslator.SequenceMethodTranslator.Translate(ExpressionConverter parent, MethodCallExpression call, SequenceMethod sequenceMethod)
w System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.MethodCallTranslator.TypedTranslate(ExpressionConverter parent, MethodCallExpression linq)
w System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.TypedTranslator`1.Translate(ExpressionConverter parent, Expression linq)
w System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.TranslateExpression(Expression linq)
w System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.TranslateSet(Expression linq)
w System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.MethodCallTranslator.AggregateTranslator.Translate(ExpressionConverter parent, MethodCallExpression call)
w System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.MethodCallTranslator.SequenceMethodTranslator.Translate(ExpressionConverter parent, MethodCallExpression call, SequenceMethod sequenceMethod)
w System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.MethodCallTranslator.TypedTranslate(ExpressionConverter parent, MethodCallExpression linq)
w System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.TypedTranslator`1.Translate(ExpressionConverter parent, Expression linq)
w System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.TranslateExpression(Expression linq)
w System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.Convert()
w System.Data.Entity.Core.Objects.ELinq.ELinqQueryState.GetExecutionPlan(Nullable`1 forMergeOption)
w System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClass7.<GetResults>b__6()
w System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
w System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClass7.<GetResults>b__5()
w System.Data.Entity.Infrastructure.DefaultExecutionStrategy.Execute[TResult](Func`1 operation)
w System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
w System.Data.Entity.Core.Objects.ObjectQuery`1.<System.Collections.Generic.IEnumerable<T>.GetEnumerator>b__0()
w System.Data.Entity.Internal.LazyEnumerator`1.MoveNext()
w System.Linq.Enumerable.<CastIterator>d__b1`1.MoveNext()
w System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)
w System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.<GetElementFunction>b__3[TResult](IEnumerable`1 sequence)
w System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.ExecuteSingle[TResult](IEnumerable`1 query, Expression queryRoot)
w System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute(Expression expression)
w System.Data.Entity.Internal.Linq.DbQueryProvider.Execute(Expression expression)
w Telerik.Windows.Data.QueryableExtensions.Count(IQueryable source)
w Telerik.Windows.Data.VirtualQueryableCollectionView..ctor(IEnumerable source, Type itemType)
w Telerik.Windows.Data.VirtualQueryableCollectionView..ctor(IEnumerable source)
w Xplus.RNX.WpfClient.UI.ViewModels.MainViewModel.FillCollections() w d:\Users\ppiechnik\Documents\Visual Studio 2012\Projects\RNX\Xplus.RNX\Xplus.RNX.WpfClient\UI\ViewModels\MainViewModel.cs:wiersz 743
InnerException:
Are there any possibilities to force VirtualQueryableCollectionView to map loaded objects to other objects.