При использовании Linq действительно ли DbNull эквивалентен Пустому указателю?

SELECT 'yellow' as color ,COUNT(*) FROM t_table WHERE color = 'YELLOW'
union
SELECT 'blue' , COUNT(*) FROM t_table WHERE color = 'BLUE'
union
SELECT 'red',COUNT(*) FROM t_table WHERE color = 'RED';

или

select color, count(*) from table where color in ('red', 'blue', 'yellow') group by 1
6
задан Alex 1 June 2009 в 20:09
поделиться

2 ответа

You shouldn't use DBNull with LinqToSql. The point is Language Integration, and so one concept or name for null will suffice.

12
ответ дан 8 December 2019 в 17:26
поделиться

In LINQ to SQL, you should be using null rather than DBNull. LINQ to SQL is an OR mapper, so it works with objects in a native way. The whole goal with L2S is to allow you to work with objects in a standard .NET way, and let L2S handle all the mapping between native and DB specific for you. You should avoid using DBNull in any L2S statements...in fact, I'm not even sure that is even a valid check (it'll probably cause some odd behavior if it works at all.)

0
ответ дан 8 December 2019 в 17:26
поделиться
Другие вопросы по тегам:

Похожие вопросы: