本文整理汇总了C#中System.Data.DataColumn.Count方法的典型用法代码示例。如果您正苦于以下问题:C# DataColumn.Count方法的具体用法?C# DataColumn.Count怎么用?C# DataColumn.Count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.DataColumn
的用法示例。
在下文中一共展示了DataColumn.Count方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MakeKeyFilter
private string MakeKeyFilter(DataColumn[] keyFields, object[] keyValues)
{
var subexpr = new string[keyFields.Count()];
for (int i = 0; i < keyFields.Count(); i++)
{
subexpr[i] = string.Format("({0}={1})", keyFields[i], SqlTypeUtil.GetFormattedValue (keyValues[i]));
}
return string.Format(subexpr.Count() > 1? "({0})": "{0}", string.Join(" and ", subexpr));
}
示例2: getDifferentRecords
//private void UpdateUiFromSelectedItem(CustomizationFunction customizationFunction) {
// pnlParameters.Controls.Clear();
// txtFunctionName.Text = customizationFunction.localName;
// txtDescription.Text = customizationFunction.localDescription;
// for (int i = 0; i < customizationFunction.localVariableTypeAndName.Count; i++) {
// for (int j = 0; j < customizationFunction.localVariableTypeAndName.ElementAt(i).Value.Count; j++) {
// Label lbl = new Label();
// lbl.Visible = false;
// lbl.Text = customizationFunction.localVariableTypeAndName.ElementAt(i).Value[j].Substring(0, 1).ToUpperInvariant() +
// customizationFunction.localVariableTypeAndName.ElementAt(i).Value[j].Substring(1);
// lbl.Dock = DockStyle.Top;
// if (string.Equals(customizationFunction.localVariableTypeAndName.ElementAt(i).Key, "boolean")) {
// ComboBox cbo = new ComboBox();
// cbo.Visible = false;
// cbo.Items.Add("True");
// cbo.Items.Add("False");
// cbo.DropDownStyle = ComboBoxStyle.DropDown;
// cbo.Name = customizationFunction.localVariableTypeAndName.ElementAt(i).Value[j];
// cbo.Dock = DockStyle.Top;
// cbo.SelectedIndex = 0;
// cbo.ContextMenuStrip = cmsAddPropertyMenu;
// pnlParameters.Controls.Add(cbo);
// pnlParameters.Controls.Add(lbl);
// } else {
// TextBox txt = new TextBox();
// txt.Visible = false;
// txt.Name = customizationFunction.localVariableTypeAndName.ElementAt(i).Value[j];
// txt.Dock = DockStyle.Top;
// //txt.Text = "\"\"";
// txt.ContextMenuStrip = cmsAddPropertyMenu;
// pnlParameters.Controls.Add(txt);
// pnlParameters.Controls.Add(lbl);
// }
// }
// }
// foreach (Control control in pnlParameters.Controls) {
// control.Visible = true;
// }
//}
private System.Data.DataTable getDifferentRecords(System.Data.DataTable FirstDataTable, System.Data.DataTable SecondDataTable)
{
//Create Empty Table
System.Data.DataTable ResultDataTable = new System.Data.DataTable("ResultDataTable");
//use a Dataset to make use of a DataRelation object
using (DataSet ds = new DataSet()) {
//Add tables
ds.Tables.AddRange(new System.Data.DataTable[] { FirstDataTable.Copy(), SecondDataTable.Copy() });
//Get Columns for DataRelation
DataColumn[] firstColumns = new DataColumn[ds.Tables[0].Columns.Count];
for (int i = 0; i < firstColumns.Length; i++) {
firstColumns[i] = ds.Tables[0].Columns[i];
}
DataColumn[] secondColumns = new DataColumn[ds.Tables[1].Columns.Count];
for (int i = 0; i < secondColumns.Length; i++) {
secondColumns[i] = ds.Tables[1].Columns[i];
}
if (firstColumns.Count() == secondColumns.Count()) {
//Create DataRelation
DataRelation r1 = new DataRelation(string.Empty, firstColumns, secondColumns, false);
ds.Relations.Add(r1);
DataRelation r2 = new DataRelation(string.Empty, secondColumns, firstColumns, false);
ds.Relations.Add(r2);
//Create columns for return table
for (int i = 0; i < FirstDataTable.Columns.Count; i++) {
ResultDataTable.Columns.Add(FirstDataTable.Columns[i].ColumnName, FirstDataTable.Columns[i].DataType);
}
ResultDataTable.Columns.Add("Added/Removed");
//If FirstDataTable Row not in SecondDataTable, Add to ResultDataTable.
ResultDataTable.BeginLoadData();
foreach (DataRow parentrow in ds.Tables[0].Rows) {
object[] rowItems = new object[parentrow.ItemArray.Length + 1];
DataRow[] childrows = parentrow.GetChildRows(r1);
if (childrows == null || childrows.Length == 0) {
parentrow.ItemArray.CopyTo(rowItems, 0);
rowItems[rowItems.Length - 1] = "Removed";
ResultDataTable.LoadDataRow(rowItems, true);
}
}
//If SecondDataTable Row not in FirstDataTable, Add to ResultDataTable.
foreach (DataRow parentrow in ds.Tables[1].Rows) {
object[] rowItems = new object[parentrow.ItemArray.Length + 1];
DataRow[] childrows = parentrow.GetChildRows(r2);
if (childrows == null || childrows.Length == 0) {
parentrow.ItemArray.CopyTo(rowItems, 0);
rowItems[rowItems.Length - 1] = "Added";
ResultDataTable.LoadDataRow(rowItems, true);
}
}
ResultDataTable.EndLoadData();
} else {
FrontendUtils.ShowInformation("Excell sheet named [" + ds.Tables[0].TableName + "] is incomparable!", true);
//.........这里部分代码省略.........