Hi,
I've found a LINQ translation error : this was working before (at least with 4.3 RC)
[attachment=0:1719v9hg]TestLinkBug.zip[/attachment:1719v9hg]
Model:
[Serializable]
[HierarchyRoot]
public class MyEntity : Entity
{
[Field, Key]
public int Id { get; private set; }
[Field]
public string Text { get; set; }
[Field, Association(PairTo = "LinkSource", OnOwnerRemove = OnRemoveAction.Cascade, OnTargetRemove = OnRemoveAction.Clear)]
public EntitySet<Link> LinksFromThis { get; private set; }
[Field, Association(PairTo = "LinkDestination", OnOwnerRemove = OnRemoveAction.Cascade, OnTargetRemove = OnRemoveAction.Clear)]
public EntitySet<Link> LinksToThis { get; private set; }
}
[HierarchyRoot]
public class Link : Entity
{
[Field, Key]
public long Id { get; private set; }
[Field]
public MyEntity LinkSource { get; set; }
[Field]
public MyEntity LinkDestination { get; set; }
}
Query
var query = from link in Query.All<Link>()
where link.LinkSource == source
where link.LinkDestination.Text == "test2"
select link.LinkDestination;
query.ToList();
Exception:
Xtensive.Storage.Linq.TranslationException was unhandled
Message=Unable to translate 'Query.All().Where(link => (link.LinkSource == @.source)).Where(link => (link.LinkDestination.Text == "test2")).Select(link => link.LinkDestination)' expression. See inner exception for details.
Source=Xtensive.Storage
StackTrace:
at Xtensive.Storage.Linq.QueryProvider.Translate[TResult](Expression expression)
at Xtensive.Storage.Linq.QueryProvider.Execute[TResult](Expression expression)
at Xtensive.Storage.Linq.Queryable`1.GetEnumerator()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at TestLinkBug.Program.Main(String[] args) in c:\users\jbenoit.serensia\documents\visual studio 2010\Projects\TestLinkBug\TestLinkBug\Program.cs:line 45
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
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()
InnerException: System.InvalidOperationException
Message=Internal error: Unable to remap KeyExpression.
Source=Xtensive.Storage
StackTrace:
at Xtensive.Storage.Linq.Expressions.KeyExpression.Remap(Int32[] map, Dictionary`2 processedExpressions)
at Xtensive.Storage.Linq.Expressions.EntityExpression.Remap(Int32[] map, Dictionary`2 processedExpressions)
at Xtensive.Storage.Linq.Expressions.EntityFieldExpression.Remap(Int32[] map, Dictionary`2 processedExpressions)
at Xtensive.Storage.Linq.Expressions.ItemProjectorExpression.<>c__DisplayClass4.<Remap>b__3(IMappedExpression mapped)
at Xtensive.Storage.Linq.Expressions.Visitors.GenericExpressionVisitor`1.VisitGenericExpression(T generic)
at Xtensive.Storage.Linq.Expressions.Visitors.GenericExpressionVisitor`1.VisitUnknown(Expression e)
at Xtensive.Core.Linq.ExpressionVisitor`1.Visit(Expression e)
at Xtensive.Storage.Linq.Expressions.Visitors.GenericExpressionVisitor`1.Process(Expression target, Func`2 genericProcessor)
at Xtensive.Storage.Linq.Expressions.ItemProjectorExpression.Remap(RecordSet dataSource, Int32[] columnMap)
at Xtensive.Storage.Linq.Translator.Optimize(ProjectionExpression origin)
at Xtensive.Storage.Linq.Translator.Translate[TResult](ProjectionExpression projection, IEnumerable`1 tupleParameterBindings)
at Xtensive.Storage.Linq.Translator.Translate[TResult]()
at Xtensive.Storage.Linq.QueryProvider.Translate[TResult](Expression expression)
InnerException:
Regards,
Julien
This thread was imported from our support forum. The original discussion may contain more detailed answer.
asked
Jul 21 '10 at 15:49
olorin
358●87●87●92
To be fixed.
Fixed.