Hi,
This should be quite simple but I'm struggling. I want to perform the following query in postgres (using postgis), LLBLGen v2.6, adapter, std templates.
select * from "Thing"
where ST_Intersects("LocationGeom", 'POINT (1 2)') = TRUE
The 1st attempt was:
DataAccessAdapter adapter = new DataAccessAdapter();
EntityCollection things = new EntityCollection(new ThingEntityFactory());
DbFunctionCall ST_Intersects = new DbFunctionCall("ST_Intersects", new object[] { ThingFields.LocationGeom, wkt});
IPredicate SpatialFilter = new EntityField("Intersects", ST_Intersects) == true;
IRelationPredicateBucket bucket = new RelationPredicateBucket();
bucket.PredicateExpression.Add(SpatialFilter);
adapter.FetchEntityCollection(things, bucket);
And the 2nd attempt was:
DataAccessAdapter adapter = new DataAccessAdapter();
EntityCollection things = new EntityCollection(new ThingEntityFactory());
DbFunctionCall ST_Intersects = new DbFunctionCall("ST_Intersects({0},{1})", new object[] { ThingFields.LocationGeom, wkt});
IPredicate SpatialFilter = new EntityField("Intersects", ST_Intersects) == true;
IRelationPredicateBucket bucket = new RelationPredicateBucket();
bucket.PredicateExpression.Add(SpatialFilter);
adapter.FetchEntityCollection(things, bucket);
3rd attempt:
DataAccessAdapter adapter = new DataAccessAdapter();
EntityCollection things = new EntityCollection(new ThingEntityFactory());
DbFunctionCall ST_Intersects = new DbFunctionCall("ST_Intersects({0},{1})", new object[] { ThingFields.LocationGeom, wkt });
EntityField fieldWithSubString = new EntityField("SkuSubstring", ST_Intersects);
IRelationPredicateBucket bucket = new RelationPredicateBucket();
bucket.PredicateExpression.Add(fieldWithSubString == true);
adapter.FetchEntityCollection(things, bucket);
Does anyone have an idea what basic thing I'm missing? I always get a nullref exception when it's trying to build the query:
at SD.LLBLGen.Pro.DQE.PostgreSql.PostgreSqlSpecificCreator.CreateObjectName(IFieldPersistenceInfo persistenceInfo)
at SD.LLBLGen.Pro.DQE.PostgreSql.PostgreSqlSpecificCreator.CreateFieldName(IFieldPersistenceInfo persistenceInfo, String fieldName, String objectAlias, Boolean appendAlias, String containingObjectName, String actualContainingObjectName)
at SD.LLBLGen.Pro.ORMSupportClasses.DbSpecificCreatorBase.ConvertFieldToRawName(IEntityFieldCore fieldCore, IFieldPersistenceInfo persistenceInfo, String fieldName, String objectAlias, Int32& uniqueMarker, Boolean applyAggregateFunction)
at SD.LLBLGen.Pro.DQE.PostgreSql.PostgreSqlSpecificCreator.CreateFieldName(IEntityFieldCore fieldCore, IFieldPersistenceInfo persistenceInfo, String fieldName, String objectAlias, Int32& uniqueMarker, Boolean applyAggregateFunction)
at SD.LLBLGen.Pro.ORMSupportClasses.DbFunctionCall.CreateParameterFragments(Int32& uniqueMarker, Boolean inHavingClause)
at SD.LLBLGen.Pro.ORMSupportClasses.DbFunctionCall.ToQueryText(Int32& uniqueMarker, Boolean inHavingClause)
at SD.LLBLGen.Pro.ORMSupportClasses.DbFunctionCall.SD.LLBLGen.Pro.ORMSupportClasses.IExpression.ToQueryText(Int32& uniqueMarker, Boolean inHavingClause)
at SD.LLBLGen.Pro.ORMSupportClasses.DbSpecificCreatorBase.ConvertFieldToRawName(IEntityFieldCore fieldCore, IFieldPersistenceInfo persistenceInfo, String fieldName, String objectAlias, Int32& uniqueMarker, Boolean applyAggregateFunction)
at SD.LLBLGen.Pro.DQE.PostgreSql.PostgreSqlSpecificCreator.CreateFieldName(IEntityFieldCore fieldCore, IFieldPersistenceInfo persistenceInfo, String fieldName, String objectAlias, Int32& uniqueMarker, Boolean applyAggregateFunction)
at SD.LLBLGen.Pro.ORMSupportClasses.FieldCompareValuePredicate.ToQueryText(Int32& uniqueMarker, Boolean inHavingClause)
at SD.LLBLGen.Pro.ORMSupportClasses.PredicateExpression.ToQueryText(Int32& uniqueMarker, Boolean inHavingClause)
at SD.LLBLGen.Pro.ORMSupportClasses.PredicateExpression.ToQueryText(Int32& uniqueMarker, Boolean inHavingClause)
at SD.LLBLGen.Pro.ORMSupportClasses.PredicateExpression.ToQueryText(Int32& uniqueMarker)
at SD.LLBLGen.Pro.DQE.PostgreSql.DynamicQueryEngine.CreateSelectDQ(IEntityFieldCore[] selectList, IFieldPersistenceInfo[] fieldsPersistenceInfo, IDbConnection connectionToUse, IPredicate selectFilter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relationsToWalk, Boolean allowDuplicates, IGroupByCollection groupByClause, Boolean relationsSpecified, Boolean sortClausesSpecified)