Problems with FetchExcludedFields with readonly or enum fields

Posts   
 
    
Posts: 98
Joined: 10-Nov-2006
# Posted on: 01-Nov-2010 22:06:20   

LLBLGen 3.0 Runtime: 3.0.10.1025 SelfServicing, .NET 4.0 SQLServer database

I have some fairly simple code that uses an IncludeFieldList to retrieve only 1 field from the database:

IncludeFieldsList includeFields = new IncludeFieldsList(XFields.Y);

XCollection c = new XCollection();
c.GetMulti(predicate, includeFields, null);

Then, for some of the entities in the collection, I want to fetch all the fields:


XEntity x = c[0];
x.FetchExcludedFields(includeFields);

But, I'm getting Exceptions thrown in two cases:

First, my entity includes a Read-Only field (marked as such in the designer). It's not included in the IncludeFieldList, so I it should be fetched when FetchExcludedFields is called. But, I see this exception:

SD.LLBLGen.Pro.ORMSupportClasses.ORMFieldIsReadonlyException occurred
  Message=The field 'RowVersion' is read-only and can't be changed.
  Source=SD.LLBLGen.Pro.ORMSupportClasses.NET20
  RuntimeBuild=10252010
  RuntimeVersion=3.0.0.0
  StackTrace:
       >    SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll!SD.LLBLGen.Pro.ORMSupportClasses.EntityBase.ValidateValue(SD.LLBLGen.Pro.ORMSupportClasses.IFieldInfo fieldToValidate, ref object value, int fieldIndex) Line 3707   C#
    SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll!SD.LLBLGen.Pro.ORMSupportClasses. EntityBase.SetValue(int fieldIndex, object value, bool checkForRefetch, bool performDesyncForFKFields) Line 2491 + 0x10 bytes  C#
    SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll!SD.LLBLGen.Pro.ORMSupportClasses. EntityBase.SetNewFieldValue(string fieldName, object value) Line 1311 + 0x19 bytes C#
    SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll!SD.LLBLGen.Pro.ORMSupportClasses. DaoBase.FetchExcludedFieldsBatches(SD.LLBLGen.Pro.ORMSupportClasses.IEntityCollection entities, SD.LLBLGen.Pro.ORMSupportClasses.ITransaction containingTransaction, System.Collections.Generic.IList<SD.LLBLGen.Pro.ORMSupportClasses.IEntityField> allPkFields, int batchSize, int numberOfPkFields, int numberOfBatches, SD.LLBLGen.Pro.ORMSupportClasses.IRelationCollection relationsToUse, System.Collections.IList excludedFieldsToUse, SD.LLBLGen.Pro.ORMSupportClasses.IEntityFields resultFields) Line 2964 + 0x7c bytes C#
    SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll!SD.LLBLGen.Pro.ORMSupportClasses. DaoBase.FetchExcludedFields(SD.LLBLGen.Pro.ORMSupportClasses.IEntityCollection entities, SD.LLBLGen.Pro.ORMSupportClasses.ITransaction containingTransaction, SD.LLBLGen.Pro.ORMSupportClasses.ExcludeIncludeFieldsList excludedIncludedFields) Line 1934 + 0x29 bytes C#
    SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll!SD.LLBLGen.Pro.ORMSupportClasses. DaoBase.FetchExcludedFields(SD.LLBLGen.Pro.ORMSupportClasses.IEntity entity, SD.LLBLGen.Pro.ORMSupportClasses.ITransaction containingTransaction, SD.LLBLGen.Pro.ORMSupportClasses.ExcludeIncludeFieldsList excludedIncludedFields) Line 1859 + 0xf bytes  C#
    SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll!SD.LLBLGen.Pro.ORMSupportClasses. EntityBase.FetchExcludedFields(SD.LLBLGen.Pro.ORMSupportClasses.ExcludeIncludeFieldsList excludedIncludedFields) Line 1179 + 0xe bytes C#




Second, one of the fields in my entity is mapped to an Enum, using the basic enum support in 3.0 (not a custom type converter). This field is not included in the IncludeFieldsList, so it should be fetched when FetchExcludedFields is called. But, I see this exception:

SD.LLBLGen.Pro.ORMSupportClasses.ORMValueTypeMismatchException occurred
  Message=The value 1 is of type 'System.Byte' while the field is of type 'Auctionpay.Aesop.LLBLGenTypes.SupporterType'
  Source=SD.LLBLGen.Pro.ORMSupportClasses.NET20
  RuntimeBuild=10252010
  RuntimeVersion=3.0.0.0
  StackTrace:
>   SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll!SD.LLBLGen.Pro.ORMSupportClasses. EntityBase.ValidateValue(SD.LLBLGen.Pro.ORMSupportClasses.IFieldInfo fieldToValidate, ref object value, int fieldIndex) Line 3709 + 0x1f bytes C#
    SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll!SD.LLBLGen.Pro.ORMSupportClasses. EntityBase.SetValue(int fieldIndex, object value, bool checkForRefetch, bool performDesyncForFKFields) Line 2491 + 0x10 bytes  C#
    SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll!SD.LLBLGen.Pro.ORMSupportClasses. EntityBase.SetNewFieldValue(string fieldName, object value) Line 1311 + 0x19 bytes C#
    SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll!SD.LLBLGen.Pro.ORMSupportClasses. DaoBase.FetchExcludedFieldsBatches(SD.LLBLGen.Pro.ORMSupportClasses.IEntityCollection entities, SD.LLBLGen.Pro.ORMSupportClasses.ITransaction containingTransaction, System.Collections.Generic.IList<SD.LLBLGen.Pro.ORMSupportClasses.IEntityField> allPkFields, int batchSize, int numberOfPkFields, int numberOfBatches, SD.LLBLGen.Pro.ORMSupportClasses.IRelationCollection relationsToUse, System.Collections.IList excludedFieldsToUse, SD.LLBLGen.Pro.ORMSupportClasses.IEntityFields resultFields) Line 2964 + 0x7c bytes C#
    SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll!SD.LLBLGen.Pro.ORMSupportClasses. DaoBase.FetchExcludedFields(SD.LLBLGen.Pro.ORMSupportClasses.IEntityCollection entities, SD.LLBLGen.Pro.ORMSupportClasses.ITransaction containingTransaction, SD.LLBLGen.Pro.ORMSupportClasses.ExcludeIncludeFieldsList excludedIncludedFields) Line 1934 + 0x29 bytes C#
    SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll!SD.LLBLGen.Pro.ORMSupportClasses. DaoBase.FetchExcludedFields(SD.LLBLGen.Pro.ORMSupportClasses.IEntity entity, SD.LLBLGen.Pro.ORMSupportClasses.ITransaction containingTransaction, SD.LLBLGen.Pro.ORMSupportClasses.ExcludeIncludeFieldsList excludedIncludedFields) Line 1859 + 0xf bytes  C#
    SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll!SD.LLBLGen.Pro.ORMSupportClasses. EntityBase.FetchExcludedFields(SD.LLBLGen.Pro.ORMSupportClasses.ExcludeIncludeFieldsList excludedIncludedFields) Line 1179 + 0xe bytes C#

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 02-Nov-2010 09:11:01   

Is that one field you are fetching the PK of the entity? If not, please include the PK field in the first fetch routine, and see if this solves anything.

If not, please attach a simple repro better on Northwind.

btw, is that entity being fetched a part of an inheritance hierarchy?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 02-Nov-2010 14:17:25   

Both should work fine. We'll look into whether we can reproduce them.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 02-Nov-2010 17:59:10   

Could you test the attached dll please?

Frans Bouma | Lead developer LLBLGen Pro
Posts: 98
Joined: 10-Nov-2006
# Posted on: 02-Nov-2010 19:02:28   

The attached dll fixes both issues.

Thanks!