The legacy database I'm working with has a table with the following example information:
LiabilityType 134 137 140 143 146 999 001 003 006 009
These codes actually contain two bits of information:
- Whether debt is classified as an expense or liability (when you run the code with an expense of "1" β; if it starts with an obligation of "0" β
- Type of debt (e.g. pledge, funeral expenses, overdraft, etc.).
Thus, I would like to map this field to two properties in my entity.
I looked at ICompositeUserType, but it looks like matching two fields with one (composite) property, rather than matching one field with two properties.
I see how I can create two classes that implement IUserType that examine this field and convert it to the correct property values, but I cannot understand how the class will convert the properties back to the corresponding database values. For example, I would like to map this so that I can create a linq query where I can say:
.Where(x => x.ExpenseOrLiability == ExpenseOrLiability.Expense)
and it will be converted to SQL as follows:
WHERE LiabilityType LIKE '1%'.
Is it possible?
David source share