开发者

BLToolkit MapValue not mapping

开发者 https://www.devze.com 2023-02-04 02:27 出处:网络
We are starting to do a conversion to BL Toolkit but are hitting some issues and not finding answers. One such issue is the inability to get the MapValue attribute on our DTO\'s properly to map.

We are starting to do a conversion to BL Toolkit but are hitting some issues and not finding answers. One such issue is the inability to get the MapValue attribute on our DTO's properly to map.

Using T4 temp开发者_如何学运维lates, we generate this (as an example):

[MapField("counterparty_fl")]
[MapValue(true,  'y')]
[MapValue(false, 'n')]
public bool CounterpartyFlag { get; set; } // flag_yn_TY(1)  

Our database is Sybase, and the field counterparty_fl is a char(1) that accepts either 'y' or 'n'.

However, when I look at the SQL generated by the following link query, it is writing [counterparty_fl] = 0. What I need is [counterparty_fl] = 'n'

var results = (from i in facade.InputList
               where (
                   i.UserIdentifier == criteria.UserId &&
                   i.CounterpartyFlag == false &&
                   i.Name == criteria.Name)
               select i);  

Has anyone had better luck with MapValue? Any suggestions?


This type of mapping is not supported for linq queries. The problem is that CounterpartyFlag field can be mapped to 'y', 'n' values, but 'false' in your expression can't be.

You can use enum for CounterpartyFlag field type:

public enum
{
    [MapValue('y')] Yes,
    [MapValue('n')] No
}

This should work.

0

精彩评论

暂无评论...
验证码 换一张
取 消