When I execute the code:
public List<T> GetCustomerTxList(int customerId)
{
var matchingPocos = new List<T>();
using (linq.AOMSEntities dataRepos = new linq.AOMSEntities())
{
IEnumerable txlist = from t in dataRepos.TransactionRecord
where t.CustomerReference.Value.Id == customerId
select t;
foreach (EntityObject entity in txlist)
{
matchingPocos.Add(entity.ConvertToPoco<T>());
}
}
return matchingPocos;
}
I get the following exception: Data.Repository.Integration.Test.LinqRepositoryTest.GetCustomerTxList: System.NotSupportedException : The specified type member 'CustomerReference' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.
CustomerReference is an EntityReference on the TransactionRecord entity referencing a Customer entity.
Why can I not query using an entity reference?
What is the recommended approach to perform such a query?
I'll gladly provide more info/code if it helps.
You should be able to access the Customer directly in your query like this:
Under the covers EF will use the CustomerReference for you in this case.