This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi, I have loaded a collection of entities and now would like to populate a collection within the list of results on each entity. I use the following to retrieve the list of zones, this works as it should result = (from zone in uow.Zones join detail in uow.ZoneSetDetails on zone.Id equals detail.ZoneId where detail.ZoneSetId == zoneSetId && detail.DeletedOn == null && zone.DeletedOn == null select zone).ToList(); now, the Zone object has a collection of properties (called Properties) which I would like to populate, I am trying to do this using the member.foreach() of the results collecton as follows result.ForEach(x => x.Properties = (from property in uow.ApplicationProperties join definition in uow.ApplicationPropertyDefs on property.PropertyDefId equals definition.Id join zone in result on property.RecordId equals zone.Id where definition.TableName.ToLower() == "zone" select property).ToList()); The ApplicationProperties table is a multivalue table holding values by table, category, property I get the following error when the second query runs. System.NotSupportedException: Specified method is not supported. at Mindscape.LightSpeed.Linq.Plan.LinqQueryBuilder.VisitConstant(ConstantExpression c) at Mindscape.LightSpeed.Linq.Plan.LinqQueryBuilder.Visit(Expression exp) at Mindscape.LightSpeed.Linq.Sqo.Join.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.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.Sqo.Select.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() Thankyou in advance. Mike |
|
|
The error is being raised because you are trying to join on a client side collection in your statement.
So you will either need to break the query apart so you can fetch the server side parts first and then join on zone and perform the remaining filtering client side or alternatively you could select out a list of the ZoneId's (e.g. result.Select(z => z.Id).ToList()) and use a .Contains clause to filter property.RecordId.
|
|
|
Jeremy, Thankyou for your help as always. Just as the email from you come in I had just tested the change to the query and have it working, I realised what the issue was with the client join after sitting back looking at it LOL. Query now is as follows. result.ForEach(x => x.Properties =
(from property in uow.ApplicationProperties
join definition in uow.ApplicationPropertyDefs on property.PropertyDefId equals definition.Id Thankyou again. |
|