Hi there
Can you please tell what's wrong with the code snippet given below I am getting this error
"Object reference not set to an instance of an object."
OrderCollection oOrderCollection = new OrderCollection();
ResultsetFields oResultsetFields = new ResultsetFields(2);
RelationCollection oRelationCollection = new RelationCollection();
IPredicateExpression oPredicateExpression = new PredicateExpression();
PredicateExpression oPredicateExpressionParent = new PredicateExpression();
IPrefetchPath oPrefetchPath = new PrefetchPath(EntityType.OrderEntity);
ISortExpression oSortExpression = new SortExpression();
EntityField installmentAmount = new EntityField("InstallmentAmount", OrderFields.Amount * 1, AggregateFunction.Sum, typeof(decimal));
oResultsetFields.DefineField(OrderFields.ParentOrder, 0);
oResultsetFields.DefineField(installmentAmount, 1);
oPredicateExpression.Add(OrderFields.ParentOrder != DBNull.Value);
oPredicateExpression.AddWithAnd(OrderFields.ClientId == clientId);
oPredicateExpression.AddWithAnd(OrderFields.OrderStatus != OrdersEnum.OrderStatus.Cancelled);
GroupByCollection oGroupByCollection = new GroupByCollection(oResultsetFields[0]);
DerivedTableDefinition oDerivedTableDefinition = new DerivedTableDefinition(oResultsetFields, "Installments", oPredicateExpression, oGroupByCollection);
IDynamicRelation oDynamicRelation = new DynamicRelation(oDerivedTableDefinition, JoinHint.Inner, EntityType.OrderEntity, "O", ((new EntityField(OrderFieldIndex.ParentOrder.ToString(), "Installments", typeof(int)) == OrderFields.Id.SetObjectAlias("O"))));
oRelationCollection.Add(oDynamicRelation);
oRelationCollection.SelectListAlias = "O";
oPredicateExpressionParent.Add(new EntityField2("InstallmentAmount", "Installments", typeof(decimal)) != OrderFields.Amount.SetObjectAlias("O"));
oPredicateExpressionParent.AddWithAnd(OrderFields.ClientId.SetObjectAlias("O") == clientId);
oPrefetchPath.Add(OrderEntity.PrefetchPathOrders, 0, oPredicateExpression);
oOrderCollection.GetMulti(oPredicateExpressionParent, oRelationCollection);
and the stack trace of the error is as follows:
at SD.LLBLGen.Pro.ORMSupportClasses.DbSpecificCreatorBase.CreateParameter(IEntityFieldCore field, IFieldPersistenceInfo persistenceInfo, ParameterDirection direction, Object valueToSet)
at SD.LLBLGen.Pro.ORMSupportClasses.FieldCompareValuePredicate.ToQueryText(Boolean inHavingClause)
at SD.LLBLGen.Pro.ORMSupportClasses.PredicateExpression.ToQueryText(Boolean inHavingClause)
at SD.LLBLGen.Pro.ORMSupportClasses.PredicateExpression.ToQueryText(Boolean inHavingClause)
at SD.LLBLGen.Pro.ORMSupportClasses.DynamicQueryEngineBase.AppendWhereClause(IPredicate filter, QueryFragments destination, IQuery query)
at SD.LLBLGen.Pro.DQE.SqlServer.DynamicQueryEngine.CreateSelectDQ(IEntityFieldCore[] selectList, IFieldPersistenceInfo[] fieldsPersistenceInfo, IRetrievalQuery query, IPredicate selectFilter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relationsToWalk, Boolean allowDuplicates, IGroupByCollection groupByClause, Boolean relationsSpecified, Boolean sortClausesSpecified)
at SD.LLBLGen.Pro.ORMSupportClasses.DynamicQueryEngineBase.CreateSelectDQ(IEntityFieldCore[] selectList, IFieldPersistenceInfo[] fieldsPersistenceInfo, DbConnection connectionToUse, IPredicate selectFilter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relationsToWalk, Boolean allowDuplicates, IGroupByCollection groupByClause)
at SD.LLBLGen.Pro.DQE.SqlServer.DynamicQueryEngine.CreatePagingSelectDQ(IEntityFieldCore[] selectList, IFieldPersistenceInfo[] fieldsPersistenceInfo, DbConnection connectionToUse, IPredicate selectFilter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relationsToWalk, Boolean allowDuplicates, IGroupByCollection groupByClause, Int32 pageNumber, Int32 pageSize)
at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.PerformGetMultiAction(ITransaction containingTransaction, IEntityCollection collectionToFill, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IPredicate selectFilter, IRelationCollection relations, IPrefetchPath prefetchPathToUse, ExcludeIncludeFieldsList excludedIncludedFields, Int32 pageNumber, Int32 pageSize)
at SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase1.GetMulti(IPredicate selectFilter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relations, IPrefetchPath prefetchPathToUse, ExcludeIncludeFieldsList excludedIncludedFields, Int32 pageNumber, Int32 pageSize)
at SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase
1.GetMulti(IPredicate selectFilter, IRelationCollection relations)