C#-> ADO.NET和LINQ [英] C# -> ADO.NET and LINQ

查看:78
本文介绍了C#-> ADO.NET和LINQ的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建到表Orders(Northwind数据库)的tuped数据集
我需要:
选择一个以上订单的区域
而且我有一个查询问题,因为此表中的ShipRegion列中有许多NULL ...
下一个代码是错误的,我该如何选择ShipRegion不为NULL的行??????

I create tuped dataset to table Orders (Northwind database)
and i need:
select regions where it is more than one order
and i have a problem with query, becouse in this table many NULLs in column ShipRegion...
next code is wrong, how i can select rows where ShipRegion is not NULL ??????

var Query = from t in ordersDataTable.Orders
                       where t.ShipRegion != null
                       select t;//new { OrderID = t.OrderID, City = t.ShipCity, Region = t.ShipRegion, Country = t.ShipCountry };
           dataGridView2.DataSource = Query.AsDataView();



这是错误.....但是我如何选择ShipRegion不为NULL的行????



it is error.....but how i can select rows where ShipRegion is not NULL ??????

推荐答案

var Query = from t in ordersDataTable.Orders
                       where t.ItemArray.Any(r => r != null && r != DBNull.Value)
                       select t;//new { OrderID = t.OrderID, City = t.ShipCity, Region = t.ShipRegion, Country = t.ShipCountry };



但是我只需要在ShipRegion



But I need this only to column ShipRegion


var Query = from t in ordersDataTable.Orders
                       where t.Field<string>("ShipRegion") != null
                       select t;//new { OrderID = t.OrderID, City = t.ShipCity, Region = t.ShipRegion, Country = t.ShipCountry };</string>





YEAAAAAH)





YEAAAAAH )


这篇关于C#-&gt; ADO.NET和LINQ的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆