SPQuery 实现对列表的查询中,CAML语言是无法实现SQL中的Distinct操作,借助于.NET中DataTable和DataView来实现,主要是DataTable的ToTable(bool distinct, string[] colParam)方法。
代码如下:
Code
DataTable dtAll = GetSPList.Items.GetDataTable();
DataView dvSort = new DataView(dtAll);
string[] colName = new string[] { "SortName", "NationalName" };
DataTable dtLargeSort = dvSort.ToTable(true, colName);
DataTable dtAll = GetSPList.Items.GetDataTable();
DataView dvSort = new DataView(dtAll);
string[] colName = new string[] { "SortName", "NationalName" };
DataTable dtLargeSort = dvSort.ToTable(true, colName);