astrouk wrote:
P.S. I am going to check out now if I can set table fields to null.
Yeah, my suggestion was right. It works for table based entities and does not for view based entities.
This code
PersonEntity pentity = new PersonEntity(23043);
pentity.SetNewFieldValue((int)PersonFieldIndex.UpdatedByIdPer, null);
pentity.Description = "Updated:" + System.DateTime.Now;
pentity.Save();
results in:
Query: UPDATE "GEN_ODS"."PER_PERSON" SET "UPDATED_BY_ID"=:UpdatedByIdPer1,"DESCRIPTION"=Description2 WHERE ( "GEN_ODS"."PER_PERSON"."ID" = :Id3)
Parameter: :UpdatedByIdPer1 : Decimal. Length: 0. Precision: 0. Scale: 0. Direction: Input. Value: <undefined value>.
Parameter: Description2 : String. Length: 0. Precision: 0. Scale: 0. Direction: Input. Value: "Updated:5/30/2007 3:37:46 PM".
Parameter: :Id3 : Decimal. Length: 0. Precision: 0. Scale: 0. Direction: Input. Value: 23043.
while this
CustomerEntity entity = new CustomerEntity(23043);
bool isNullable = CustomerFields.EmployerId.SourceColumnIsNullable;
//returns false
decimal employerId = entity.EmployerId;
//returns 60135
entity.SetNewFieldValue((int)CustomerFieldIndex.EmployerId, null);
entity.Company = "Updated:" + System.DateTime.Now;
entity.Save();
corresponds to:
Query: UPDATE "GEN_ODS"."PER_CUSTOMER" SET "COMPANY"=:Company1 WHERE ( "GEN_ODS"."PER_CUSTOMER"."ID" = :Id2)
Parameter: :Company1 : String. Length: 0. Precision: 0. Scale: 0. Direction: Input. Value: "Updated:5/30/2007 3:41:04 PM".
Parameter: :Id2 : Decimal. Length: 0. Precision: 0. Scale: 0. Direction: Input. Value: 23043.
CustomerEntity is based on a view, while PersonEntity is a table based one.
Well, I think it is a bug
LLBLGen allows to update view based entities per se, but it doesn't allow to set entity fields to nulls. It doesn't throw any exception either. Besides, as I understand, LLBLGen should retrieve nullable flag from system table user_tab_columns.
select column_name, data_type, nullable from user_tab_columns where table_name = 'PER_CUSTOMER'
returns
EMPLOYER_ID, NUMBER, Y
Alex