Using LLBLGen 2.0.7.226, SelfServicing.
I have used CreateFields() to add some fields to my Entity. It all works fine until I make changes to that entity and try to Save() those changes back out.
Error:
Exception Details: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Source Error:
Line 1068: {
Line 1069: SomeEntityDAO dao = (SomeEntityDAO)CreateDAOInstance();
Line 1070: return dao.UpdateExisting(base.Fields, base.Transaction);
Line 1071: }
Line 1072:
Stack Trace:
[ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index]
System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource) +62
System.ThrowHelper.ThrowArgumentOutOfRangeException() +12
System.Collections.Generic.List1.get_Item(Int32 index) +2633204
SD.LLBLGen.Pro.ORMSupportClasses.DynamicQueryEngineBase.CreateUpdateDQ(IEntityFieldCore[] fields, IFieldPersistenceInfo[] fieldsPersistenceInfo, IDbConnection connectionToUse, List
1 pkFilters) +607
SD.LLBLGen.Pro.ORMSupportClasses.DynamicQueryEngineBase.CreateUpdateDQ(IEntityFields fields, IDbConnection connectionToUse, List1 pkFilters) +66
SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.UpdateExisting(IEntityFields fields, ITransaction containingTransaction) +611
NameSpace.DAL.EntityClasses.SomeEntityEntityBase.UpdateEntity() in DAL\EntityBaseClasses\SomeEntityEntityBase.cs:1070
NameSpace.DAL.EntityClasses.SomeEntityEntity.UpdateEntity() in DAL\EntityClasses\SomeEntityEntity2.cs:75
SD.LLBLGen.Pro.ORMSupportClasses.EntityBase.CallUpdateEntity() +27
SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.PersistQueue(List
1 queueToPersist, Boolean insertActions, ITransaction transactionToUse) +820
SD.LLBLGen.Pro.ORMSupportClasses.EntityBase.Save(IPredicate updateRestriction, Boolean recurse) +729
NameSpace.DAL.EntityClasses.SomeParentEntityBase.Save(IPredicate updateRestriction, Boolean recurse) in DAL\EntityBaseClasses\SomeParentEntityBase.cs:201
SD.LLBLGen.Pro.ORMSupportClasses.EntityBase.Save(Boolean recurse) +141
Here is the code I have added to the class:
protected override IEntityFields CreateFields()
{
IEntityFields toReturn = base.CreateFields();
toReturn.Expand(1);
IEntityField IsPolicyValid = new EntityField("IsPolicyValid", SqlFunctionFactory.IsPolicyValid(SomeEntityFields.SomeEntityId));
toReturn.DefineField(IsPolicyValid, (int)SomeEntityFieldIndexExt.IsPolicyValid);
return toReturn;
}
public enum SomeEntityFieldIndexExt : int
{
IsPolicyValid = SsomeEntityFieldIndex.AmountOfFields
}
public bool IsPolicyValid
{
get
{
return Convert.ToBoolean(this.Fields[(int)SomeEntityFieldIndexExt.IsPolicyValid].CurrentValue);
}
}
This entity is in a hierarchy - target per entity - if that matters.