private static void LinqToDataSet()
{
string sql = "select * from Advertising";
using (DataSet ds = GetDataSet(sql))
{
if (ds != null)
{
if (ds.Tables[].Rows.Count > )
{
//查询全局广告
List<Advertising> listCompany = new List<Advertising>();
Guid guid = new Guid("B362A0D1-99D2-432F-8345-28D0E0B94B88");
//查询总部和广告
var Company = from adv in ds.Tables[].AsEnumerable()
where adv.Field<int>("AdvertisingType").ToString() != "" && adv.Field<Guid>("CompanyId") == guid
orderby adv.Field<int>("AdvertisingType") ascending, adv.Field<int>("Orders") ascending
select new
{
AdvertisingId = adv.Field<Guid>("AdvertisingId"),
AdvertisingName = adv.Field<string>("AdvertisingName"),
SupplierId = adv.Field<Guid>("SupplierId"),
CompanyId = adv.Field<Guid>("CompanyId"),
AdvertisingType = adv.Field<int>("AdvertisingType"),
StartTime = adv.Field<DateTime>("StartTime"),
EndTime = adv.Field<DateTime>("EndTime"),
Orders = adv.Field<int>("Orders"),
Content = adv.Field<string>("Content"),
AdvertisingArea = adv.Field<int>("AdvertisingArea"),
FilePath = adv.Field<string>("FilePath")
}; foreach (var company in Company)
{ Advertising advertising = new Advertising();
advertising.AdvertisingId = company.AdvertisingId.ToString();
advertising.AdvertisingName = company.AdvertisingName;
advertising.SupplierIdId = company.SupplierId.ToString();
advertising.CompanyId = company.CompanyId.ToString();
advertising.AdvertisingType = company.AdvertisingType;
advertising.StartTime = company.StartTime;
advertising.EndTime = company.EndTime;
advertising.Orders = company.Orders;
advertising.Content = company.Content;
advertising.AdvertisingArea = company.AdvertisingArea;
advertising.FilePath = company.FilePath; listCompany.Add(advertising);
}
File.WriteAllText("c:/System.txt", ToJson(listSystem)); Console.WriteLine("生成完成");
// DataRow[] drCountry = ds.Tables[0].Select(where);
}
}
}
}

Linq To DataSet的更多相关文章

  1. LINQ系列:LINQ to DataSet的DataTable操作

    LINQ to DataSet需要使用System.Core.dll.System.Data.dll和System.Data.DataSetExtensions.dll,在项目中添加引用System. ...

  2. LINQ(LINQ to DataSet)

    http://www.cnblogs.com/SkySoot/archive/2012/08/21/2649471.html DataTable.Select()方法使用和 SQL 相似的过滤语法从 ...

  3. 泛型 Field 和 SetField 方法 (LINQ to DataSet)

    LINQ to DataSet 为 DataRow 类提供用于访问列值的扩展方法:Field 方法和 SetField 方法.这些方法使开发人员能够更轻松地访问列值,特别是 null 值.DataSe ...

  4. C# LINQ系列:LINQ to DataSet的DataTable操作 及 DataTable与Linq相互转换

    LINQ to DataSet需要使用System.Core.dll.System.Data.dll和System.Data.DataSetExtensions.dll,在项目中添加引用System. ...

  5. LINQ To DataSet 示例

    如果在项目遇到这样的问题如:DataTable1和DataTable2需要根据一定的规则进行合并成一个DataTable3. 问题1:DataTable1不是读数据库表的结果,而是合成的数据集,因此无 ...

  6. Linq to DataSet 和 DataSet使用方法学习

    简单入门: using System; using System.Collections.Generic; using System.Linq; using System.Text; using Sy ...

  7. LINQ系列:LINQ to DataSet的DataView操作

    1. 创建DataView EnumerableRowCollection<DataRow> expr = from p in products.AsEnumerable() orderb ...

  8. LINQ to DataSet的DataTable操作

    1. DataTable读取列表 DataSet ds = new DataSet();// 省略ds的Fill代码DataTable products = ds.Tables["Produ ...

  9. 2016.1.22 利用LINQ实现DataSet内多张DataTable关联查询操作(目前未发现太大价值)

    DataSet ds = new DataSet(); DataTable t1 = DBFactorySingleton.GetInstance().Factory.GetDataTable(sql ...

随机推荐

  1. java SE 常用的排序算法

    java程序员会用到的经典排序算法实现 常用的排序算法(以下代码包含的)有以下五类: A.插入排序(直接插入排序.希尔排序) B.交换排序(冒泡排序.快速排序) C.选择排序(直接选择排序.堆排序) ...

  2. a few changes of Android 5.0

    1.Service Intent must be explicit Intent serviceIntent = new Intent(context,MyService.class);context ...

  3. [GodLove]Wine93 Tarining Round #1

    比赛链接: http://acm.hust.edu.cn/vjudge/contest/view.action?cid=44664#overview 题目来源: 2011 Asia Regional ...

  4. HC蓝牙模块测试AT指令搭建外部电路遇到的问题

    按这个搭,AT指令烧不进去,两块板两次都不行. 这是我的底板(比较混乱的万能版) 第一次短路了,VCC和GND在板子下面连起来了,肉眼当然看不见,吹下来重新焊就好了. 第二次,txdrxd与usb转T ...

  5. option对象概念

    一.基础理解: var e = document.getElementById("selectId");   e.options = new Option("文本&quo ...

  6. 378. Kth Smallest Element in a Sorted Matrix

    Given a n x n matrix where each of the rows and columns are sorted in ascending order, find the kth ...

  7. 关于配置服务器(IIS7)

    服务器Server2003 ,无限开机动画慢动作重播,一怒而重装server2008 然,重点就是系统装好了 IIS装好了 ,发布网站 开始各种错了!!! 1.第一个错 额,错误信息说 :由于权限不足 ...

  8. 2016HUAS_ACM暑假集训2E - I Hate It

    又是一个线段树的应用,不过跟上一题(D-排兵布阵)不同的是,这次是求某段区间上的最值,而不是某段区间和.当然,数据更新是必须的.D题注释已经很详细了,所以这题注释少点. 大致题意:给你N个已经排好的学 ...

  9. [原创]cocos2d-x研习录-第二阶 基本概念

    在Cocos2D-x引擎中,有几个非常重要的概念:导演(CCDirector).摄像机(CCCamera).场景(CCSecen).布景(CCLayer).精灵(CCSPrite)和动作(CCActi ...

  10. jquery easy ui combox

    $(document).ready(function() { $.ajax({ type: 'POST', dataType: "json", url:'menu/getAll', ...