Hi guys,
I'm trying to implement a N-layered application with LS in the DAL.
Let's jump directly to the example.
Assume, we have pretty simple db model:
Next, the relationship code generation is set to "Field only". Relationship is implemented as an interface in the following manner:
Branch
public interface IBranch
{
Int32 Id { get; set; }
String Name { get; set; }
}
public partial class Branch : IBranch
{
}
User
public interface IUser
{
Int32 Id { get; set; }
String Name { get; set; }
IBranch Branch { get; set; }
}
public partial class User : IUser
{
public IBranch Branch
{
get { return Get(_branch); }
set { Set(_branch, (Branch) value); }
}
}
And then let's try to make a couple of linq queries:
var users = uow.Users.Where(x => x.Branch.Id == 1).ToList();
This query is successful. No problems.
var users = uow.Where(x => (new[] {1, 2}).Contains(x.Branch.Id)).ToList();
And this throwing an exception:
Value cannot be null. Parameter name: entityType
at Mindscape.LightSpeed.Utils.Invariant.ArgumentNotNull(Object , String )
at Mindscape.LightSpeed.Querying.PathExpression..ctor(Type entityType, String path)
at Mindscape.LightSpeed.Querying.PathExpression..ctor(Type , String , IEnumerable`1 )
at Mindscape.LightSpeed.Linq.Translations.CollectionContainsBase.Apply(QueryExpression applyTo, DataProvider provider, QueryExpression[] arguments)
at Mindscape.LightSpeed.Linq.Sqo.CriteriaSqo.ExtractMethodCriteria(LinqQueryPlanExpression plan, MethodCallExpression expression)
at Mindscape.LightSpeed.Linq.Sqo.CriteriaSqo.ExtractCriteriaCore(LinqQueryPlanExpression plan, Expression expression)
at Mindscape.LightSpeed.Linq.Sqo.CriteriaSqo.ExtractCriteria(LinqQueryPlanExpression plan, Expression expression)
at Mindscape.LightSpeed.Linq.Sqo.CriteriaSqo.ExtractCriteriaCore(LinqQueryPlanExpression plan, Expression expression)
at Mindscape.LightSpeed.Linq.Sqo.CriteriaSqo.ExtractCriteria(LinqQueryPlanExpression plan, Expression expression)
at Mindscape.LightSpeed.Linq.Sqo.CriteriaSqo.ExtractCriteriaCore(LinqQueryPlanExpression plan, Expression expression)
at Mindscape.LightSpeed.Linq.Sqo.CriteriaSqo.ExtractCriteria(LinqQueryPlanExpression plan, Expression expression)
at Mindscape.LightSpeed.Linq.Sqo.Where.ExtractWhereCriteria(MethodCallExpression expression, LinqQueryPlanExpression plan, GroupResultsPlan groupPlan)
at Mindscape.LightSpeed.Linq.Sqo.Where.Evaluate(ExpressionVisitor visitor, MethodCallExpression expression)
at Mindscape.LightSpeed.Linq.Plan.LinqQueryBuilder.VisitMethodCall(MethodCallExpression exp)
at Mindscape.LightSpeed.Linq.Plan.LinqQueryBuilder.Visit(Expression exp)
at Mindscape.LightSpeed.Linq.Plan.LinqQueryBuilder.Build(Expression translation, LinqQueryProvider provider)
at Mindscape.LightSpeed.Linq.LinqQueryProvider.GetExecutionPlan(Expression expression)
at Mindscape.LightSpeed.Linq.LinqQueryProvider.Execute(Expression expression)
at Mindscape.LightSpeed.Linq.LinqQueryProvider.System.Linq.IQueryProvider.Execute(Expression expression)
at Mindscape.LightSpeed.Linq.LinqQuery`1.GetEnumerator()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at TestLightSpeedLinqInterfaces.Program.Main()
It seems that in the first example with binary expression LS correctly extracts MemberExpression, but in the second one with method invocation expression it doesn't. Could you please check this behavior?
I've included the sample project to this thread. Do not forget to restore Nuget packages for it and set appropriate DB parameters.
P.S. I'm using Oracle as a DB provider if it makes sence.
Thanks in advance!