本文整理汇总了C#中System.Data.DataView.DetachRowsAndDispose方法的典型用法代码示例。如果您正苦于以下问题:C# DataView.DetachRowsAndDispose方法的具体用法?C# DataView.DetachRowsAndDispose怎么用?C# DataView.DetachRowsAndDispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.DataView
的用法示例。
在下文中一共展示了DataView.DetachRowsAndDispose方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PotentialMatchesSearchExecute
public void PotentialMatchesSearchExecute(PotentialClientMatchesState state)
{
// ReSharper disable InconsistentNaming
Proc Sponsor_New_Search = null;
// ReSharper restore InconsistentNaming
switch (state.FieldType)
{
case PotentialMatchFieldType.SSN:
Sponsor_New_Search = new Proc("Sponsor_New_SearchSSN");
Sponsor_New_Search["@SSN1"] = state.ClientRow["SSN1"];
Sponsor_New_Search["@SSN2"] = state.ClientRow["SSN2"];
Sponsor_New_Search["@SSN3"] = state.ClientRow["SSN3"];
break;
case PotentialMatchFieldType.Name: Sponsor_New_Search = new Proc("Sponsor_New_SearchName");
Sponsor_New_Search["@FirstName"] = state.ClientRow["FName"];
Sponsor_New_Search["@LastName"] = state.ClientRow["LName"];
break;
}
Debug.Assert(Sponsor_New_Search != null, "Sponsor_New_Search != null");
using (Sponsor_New_Search)
{
Sponsor_New_Search["@MatchType"] = string.Format("Matched on {0} {1}",
state.ClientRow.Field<bool>("IsSponsor") ? "Sponsor" :
state.ClientRow.Field<bool>("IsSpouse") ? "Spouse" :
"Dependent",
state.FieldType);
Sponsor_New_Search.ExecuteDataSet();
// if this is the first time through, just take sproc result as our backdrop table
if (PotentialClientMatches == null)
{
Sponsor_New_Search.Table0.Columns.Add("RecordCountId", typeof(int)); //backdrop table's RecordCount has to be a real value since a computed Count() would always be the same for all rows in this table
foreach (DataRow r in Sponsor_New_Search.Table0.Rows) r["RecordCountId"] = Sponsor_New_Search.Table0.Rows.Count; //fyi, can't use expression based count column because that would reflect the total rows
PotentialClientMatches = new DataView(Sponsor_New_Search.Table0) {Sort = "RecordCountId, LName, FName"};
//sort by ascending RecordCount so that the more specific matches are at the top
}
else //otherwise, just keep merging new results into the backdrop table
{
// clear out any existing match rows of the same match type, because each NewMatches batch of the same type should be considered an entirely new list of hits specific to the most recent inputs
using (var v = new DataView(PotentialClientMatches.Table))
{
v.RowFilter = String.Format("MatchType = '{0}'", Sponsor_New_Search["@MatchType"]);
v.DetachRowsAndDispose(true);
}
Sponsor_New_Search.Table0.Columns.Add("RecordCountId", typeof(int), "Count(LName)"); //bring the new rows in with their own count
PotentialClientMatches.Table.Merge(Sponsor_New_Search.Table0);
}
}
}
示例2: ClearPreviousMatches
private void ClearPreviousMatches(string MatchType)
{
if (PotentialMatches.Rows.Count == 0) return;
//clear out any existing match rows of the same match type, because each batch should be considered an entirely new list of hits
using (DataView v = new DataView(PotentialMatches))
{
v.RowFilter = "MatchType = '" + MatchType + "'";
v.DetachRowsAndDispose();
}
}