FetchEntityUsingUniqueConstraint and read-only field

Posts   
 
    
jeffryvu
User
Posts: 14
Joined: 22-Sep-2005
# Posted on: 30-Sep-2005 16:30:05   

Hi,

I have an entity with a read-only field with a unique constraint.

When I try to do FetchEntityUsingUniqueConstraint like this: entity.UserName = userName; if (adapter.FetchEntityUsingUniqueConstraint(entity, entity.ConstructFilterForUCUserName()))

I get the following error: The field 'UserName' is read-only and can't be changed.

Exception Details: SD.LLBLGen.Pro.ORMSupportClasses.ORMFieldIsReadonlyException: The field 'UserName' is read-only and can't be changed.

I understand that you shouldn't change a read-only field, but it needs to be set for the Fetch.

I guess I could do a FetchEntityCollection with the correct IRelationPredicateBucket to get the same result. But maybe there is a better way, maybe a flag I could set to be able to set the read-only field for a Fetch operation?

Thanks, Jeffry

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 30-Sep-2005 17:12:41   

Hi Jeffry

If this property is a Read-Only, then you have no way to set it.

You may use FetchNewEntity as well as FetchEntityCollection, since you only need to fetch one Entity by the unique field, and use the RelationPredicateBucket, to define a predicate with UserName needed.

And if you use FetchEntityCollection, you may specify "MaxNumberOfItemToReturn" to be 1, since you need only one item.

jeffryvu
User
Posts: 14
Joined: 22-Sep-2005
# Posted on: 02-Oct-2005 00:31:51   

Ok, thanks for the info.

I already tried the FetchEntityCollection and it works fine. I'll take a look at the FetchNewEntity.

Thanks, Jeffry