블로그 이미지
Sunny's

calendar

1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

Notice

2009. 4. 15. 16:13 LINQ


LINQ 쿼리 작성 시  특정 컬럼에 DBNULL 값이 넘어와서 오류가 생길 경우 예외 처리 방법
 

 var ProductQuery = from a in dGroupData.TbProductList
                               select new Product
                               {
                                   G_ID = a.g_id,
                                   G_Sub_ID = a.g_sub_id,
                                   Item_ID = a.item_id,
                                   Item_Name = a.item_nm,
                                   Discount_Type = a.Isdiscount_typeNull() ? "0" : a.discount_type,
                                   Discount_Value = a.Isdiscount_valueNull() ? "0" : a.discount_value,
                                   Div_Sdt = a.div_sdt,
                                   Div_Edt = a.div_edt

                               };




Is+해당 컬럼+Null() 로 DBNULL 체크가 가능함

 Discount_Type = a.Isdiscount_typeNull() ? "0" : a.discount_type,
 Discount_Value = a.Isdiscount_valueNull() ? "0" : a.discount_value,

posted by Sunny's