Print Page | Close Window

LINQ and Extended Entity Properties

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2484
Printed Date: 27-Jul-2026 at 11:02pm


Topic: LINQ and Extended Entity Properties
Posted By: rasmister
Subject: LINQ and Extended Entity Properties
Date Posted: 03-Feb-2011 at 8:56am
Folks,

I have the following query that is throwing and exception:

private IEnumerable<INotifyCompleted> GetParticipantsByNameFullCoRoutine()
{
_isBatchCompleted = false;

Participants.Clear();
var participantOp =
App.EntityManager.Participants
//.Where(p => p.NameFullFirstLast == SearchTerm)
.ExecuteAsync();

yield return participantOp;

if (participantOp.Results.Count() > 0)
{
participantOp.Results.Where(p => p.NameFullFirstLast == SearchTerm).ForEach(Participants.Add);
}

yield return Coroutine.Return(participantOp.Results);
}

The p.NameFullFirstLast is a computed value in the entity buddy class.

The exception thrown is "NameFullFirstLast" is not supported in LINQ to Entities.  Only initializers, entity members, and entity navigation pies are supported.

Is there a way to do this or am I barking up the wrong tree?

Thanks!

Ross






Replies:
Posted By: sbelini
Date Posted: 03-Feb-2011 at 4:53pm
Hi ramister,
 
I was not able to reproduce your issue here.
Here's my test case: (against NorthwindIB)
 
  var coop  = Coroutine.Start(LoadListEntitiesCoroutine);
    coop.Completed += (sender, args) => {
    // some code
  };
 
...
 
  private IEnumerable<INotifyCompleted> LoadListEntitiesCoroutine() {
  var employeesOp = _mgr.Employees.ExecuteAsync();
  yield return employeesOp;
  if (employeesOp.Results.Count() > 0) {
    employeesOp.Results.Where(c => c.FullName == "Andy Fuller").ToList().ForEach(_employees.Add);
  }
  yield return Coroutine.Return(employeesOp.Results);
}
 
...
 
List<Employee> _employees = new List<Employee>();
 
...
 
public partial class Employee : BaseClass {
  public string FullName {
    get { return FirstName + " " + LastName; }
  }
}
 
Is "NameFullFirstLast" a custom property? How is it being implemented? You might also check this thread at http://stackoverflow.com/questions/2241643/how-to-use-a-custom-property-in-a-linq-to-entities-query - http://stackoverflow.com/questions/2241643/how-to-use-a-custom-property-in-a-linq-to-entities-query .
 
Also, I'm assuming you mean to add more async operations in your coroutine, right? (otherwhise, why not just populate your list in the callback of ExecuteAsync?)
 
Silvio.



Print Page | Close Window