Hi,
in our project, all entities that have "description" fields must be made multi-language. We have solved this by moving the descriptions into a separate table "xxx_LOCALE" where all descriptions reside, one for each language.
Now the problem is that sometimes we have entities with nothing more then a description, so the entities has only one field, the autonumber primary key.
Let's say we have an entity REGION, then the DB looks like :
REGION : 1 field REGION_ID (int,PK)
REGION_LOCALE : 3 fields : REGION_ID (int,FK), LANGUAGE_ID (int,FK) and DESCRIPTION (string)
Now take the situation when we want to add such an entity to the the Database.
What i do is create a new RegionEntity, and for each available language in the system, create a RegionLocaleEntity and add it to the RegionEntity.RegionLocale collection
Now if i want so save this entity i got the error message :
An exception was caught during the execution of an action query: Cannot insert the value NULL into column 'REGION_ID', table 'AGRO.dbo.REGION_LOCALE'; column does not allow nulls. INSERT fails.
The statement has been terminated.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception.
Now after some fiddling i have set the region.IsDirty to true to mage sure the region got saved and then i got the error message :
The insert query doesn't contain any fields.
at SD.LLBLGen.Pro.ORMSupportClasses.EntityBase.Save(IPredicate updateRestriction, Boolean recurse)
at Agro.Datalayer.EntityClasses.RegionEntityBase.Save(IPredicate updateRestriction, Boolean recurse)
at SD.LLBLGen.Pro.ORMSupportClasses.UnitOfWork.Commit(ITransaction transactionToUse, Boolean autoCommit)
at Agro.Detailforms.RegionForm.PersistData()
Since i have used this mechanism at numerous other locations i'm sure it has to do with the fact there is only one (autonumbered) field in the entity. Is there any solution ?
thnx.