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. Swift语言—有趣的字符串连接、数组、字典

    字符串链接:Swift语言中的字符串连接方式本人觉得非常的有趣,变量连接需要用右斜杠,并且变量名要括起来 “\(变量名)”,后面的字符串连接分别用逗号 ‘ , ’ 隔开 数组: Var arr = [ ...

  2. Visual Studio 编译项目失败,提示找不到文件

     博客地址:http://blog.csdn.net/FoxDave 今天碰到了一个蠢问题,虽然咱们正常情况下是遇不到的,但这确实是个应该注意的地方,所以简单记录一下. Visual Studio ...

  3. python import其他文件夹下的模块

    模块的路径不在默认搜索路径中,需要在sys.path中添加 import syssys.path.append('需要模块的文件夹路径')

  4. json全套

    JS文件 function pager1_InitData() { //基础配置 $("#pager1").myPagination({ currPage: 1, pageCoun ...

  5. Python 入门指南

    Release: 3.4 Date: March 29, 2014 Python 是一门简单易学且功能强大的编程语言. 它拥有高效的高级数据结构,并且能够用简单而又高效的方式进行面向对象编程. Pyt ...

  6. iOS-音频和视频

    一.视频 视频播放器需要添加MediaPlayer.framework. 视频播放主要提供了两个类,一个MPMoviePlayerController, 另一个是MPMoviePlayerViewCo ...

  7. 一种Go使用tcp检测超时的方式

    c.SetReadDeadline(time.Now()) if _, err := c.Read(one); err == io.EOF { l.Printf(logger.LevelDebug, ...

  8. Java 设计一个贷款计算器 简易

    import javax.swing.*; import java.awt.*; import java.awt.event.*; import javax.swing.border.*; publi ...

  9. C++概念整理

    /* 面向对象: 多态, 继承 封装 */ #include <stdio.h> #include <stdlib.h> //一旦有了纯虚函数,该对象就不能实例化了. #def ...

  10. (MST) HDOJ 1102 Constructing Roads

    怎么说呢 这题就是个模板题 但是 hud你妹夫啊说好的只有一组数据呢??? 嗯??? wa到家都不认识了好吗 #include <cstdio> #include <cstring& ...