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'm getting this error: Error eager loading BankImportSetup.BankAccount (BankAccount): custom association resolvers cannot participate in eager load unless the child-to-parent resolver query expression is of the form 'Entity.Attribute("Id") == ...' Mindscape.LightSpeed.LightSpeedException: Error eager loading BankImportSetup.BankAccount (BankAccount): custom association resolvers cannot participate in eager load unless the child-to-parent resolver query expression is of the form 'Entity.Attribute("Id") == ...'
at Mindscape.LightSpeed.Model.AssociationModel.(Entity )
at Mindscape.LightSpeed.Mapping.EntityLoader.(UnitOfWorkBase , Entity ) at Mindscape.LightSpeed.Mapping.EntityLoader.LoadEntityFromReader(AliasedTypeModel, Object, Boolean) at ..(AliasedTypeModel , QueryExpression , Order , Group , String , Boolean , Boolean ) at ..(LightSpeedContext , List`1 , QueryExpression , Order , Group , String , Boolean , Boolean ) at ..(AliasedTypeModel , IList , String , Boolean ) at ..(TypeModel , Query , IList ) at ..(Query , TypeModel , IList ) at ..(Query , IList ) at Mindscape.LightSpeed.UnitOfWork.Find(Query query, IList results) at Mindscape.LightSpeed.UnitOfWorkBase.Find(Query query) at Mindscape.LightSpeed.Linq.Plan.SingleQueryPlan.ExecuteImmediate(IUnitOfWork unitOfWork, Type returnType) at Mindscape.LightSpeed.Linq.LinqQueryProvider.Execute(Expression expression) at Mindscape.LightSpeed.Linq.LinqQueryProvider.System.Linq.IQueryProvider.Execute(Expression expression) at System.Linq.Queryable.SingleOrDefault(IQueryable`1 source, Expression`1 predicate) at *snip* I'm a bit confused because there are no eagerload attributes in the entire model. It says that it's wanting this:
"child-to-parent resolver query expression is of the form 'Entity.Attribute("Id") == ...'" but that's *almost* exactly what's in the resolver.
(Yes, you can see the composite Id properties are actually nullable. Don't ask me why, it's a legacy thing. We're moving away from it as fast as we can!)
So - a) are you able to help with why it is trying to eager load (or is this just misleading) and b) is it getting annoyed with my wrapping the query expression in a guard clause?
BankImportSetup with custom assoc resolver:
public partial class BankImportSetup
{ [ReverseAssociation("BankImportSetups")] [AssociationResolver(typeof(BankImportSetupToBankAccountResolver))] private readonly EntityHolder<BankAccount> _bankAccount = new EntityHolder<BankAccount>(); public BankAccount BankAccount { get { return Get(_bankAccount); } set { Set(_bankAccount, value); } } internal class BankImportSetupToBankAccountResolver : IAssociationResolver { public QueryExpression GetQueryExpression(Entity sourceEntity) { var organisation = sourceEntity as Organisation; if (organisation != null) { return Attribute(OrganisedKey.OrganisationIdField) == organisation.Id; } var bankImportSetup = sourceEntity as BankImportSetup; if (bankImportSetup != null) { if (bankImportSetup.OrganisationId.HasValue && bankImportSetup.BankAccountId.HasValue) { return Attribute("Id") == new BankAccountId(bankImportSetup.OrganisationId.Value, bankImportSetup.BankAccountId.Value); } return null; } throw new ArgumentException("Don't know how to process this"); } public void SetForeignKey(Entity childEntity, object parentId) { } } } thanks!
|
|
|
apologies - just found out why. it's running past the queryexpression block because bankaccountid is null - so it's returning null from the method. that will be the problem... |
|