BooleanCharYNConverter and Projections

Posts   
 
    
Posts: 11
Joined: 20-Mar-2012
# Posted on: 26-Apr-2012 19:30:04   

I am using LLBL 3.5 against Oracle with MS Oracle, VS2010, C#, and .NET 4.0.

I have an entity with a bool fields mapped to Y/N Oracle string fields. This is what the mapping looks like:

Element name: IsBillToAddress Order: 1 .NET Type : bool (System.Boolean) Target element name: IsBillToAddress TypeConverter to use: SD.LLBLGen.Pro.TypeConverters.BooleanCharYNConverter

When I try to project this entity into a custom class that takes a string, the projection fails with a "The value Y is of type 'System.String' while the field is of type 'System.Boolean'" exception. Here is my projection code:

valueProjectors.Add(new DataValueProjector(CustomerAddressSequenceFields.IsBillToAddress.Alias, PSCustAddrSeqFields.BillToAddr.FieldIndex, typeof(Boolean)));

This also fails:

valueProjectors.Add(new DataValueProjector(CustomerAddressSequenceFields.IsBillToAddress.Alias, PSCustAddrSeqFields.BillToAddr.FieldIndex, typeof(BooleanCharYNConverter)));

Can this conversion be done with LLBL projection?

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 26-Apr-2012 20:08:11   

If you are using the Type converter, then the entity has the field of type boolean. You can't project this to string as the error explains.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39910
Joined: 17-Aug-2003
# Posted on: 27-Apr-2012 09:44:44   

Workaround: map another entity onto the same table, and in that entity you don't specify a type converter, so the field is a string field. Then create your projection from that entity: same data, but no conversion happens, you get the raw value (Y)

Frans Bouma | Lead developer LLBLGen Pro