限制数据集中的记录 [英] limit the records in dataset

查看:84
本文介绍了限制数据集中的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好....如何限制数据集中的记录数????

hello....How can I limit the no.of records in a dataset???

推荐答案

嗨 如果您提供一种方案,则可以更轻松地回答您的问题.我认为数据集不具有限制记录数量的属性.将记录复制到数据集时,我们可以设置要复制到数据集的记录数.
例如我们可以在LINQ中使用``Take''方法.

http://msdn.microsoft.com/en-us/library/bb503062.aspx [ ^ ]

问候
Dominic
Hi If you provide one scenario, it will be easier to answer your question. I don''t think dataset has such a property to limit the number of records. While copying records to a dataset, we can set the number of records to be copied to the dataset.
For example we can use ''Take'' method in LINQ .

http://msdn.microsoft.com/en-us/library/bb503062.aspx[^]

Regards
Dominic


DataView dataView = new DataView(dataTable);
dataView.RowFilter = String.Format("EventDate > '{0}'", DateTime.Now);
dataView.Sort = "EventDate";
dataTable = dataView.ToTable();
while (dataTable.Rows.Count > _rowLimit)
{
    dataTable = dataTable.AsEnumerable().Skip(0).Take(50).CopyToDataTable();
}
return dataTable;



我忘了说
您将需要名称空间:System.Linq和System.Data



I forgot to say
You''ll need namespace: System.Linq and System.Data


这篇关于限制数据集中的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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