本文整理汇总了C#中TableName.Where方法的典型用法代码示例。如果您正苦于以下问题:C# TableName.Where方法的具体用法?C# TableName.Where怎么用?C# TableName.Where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TableName
的用法示例。
在下文中一共展示了TableName.Where方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Search
public static TableName[] Search(string pattern, TableName[] tableNames)
{
Regex regex = pattern.WildcardRegex();
var result = tableNames.Where(tname => regex.IsMatch(tname.Name)).ToArray();
return result;
}
示例2: Run
public string Run(ActionType compareType, TableName[] N1, TableName[] N2, Configuration cfg, string[] exceptColumns)
{
DatabaseName dname1 = Side1.DatabaseName;
DatabaseName dname2 = Side2.DatabaseName;
stdio.WriteLine("server1: {0} default database:{1}", Side1.Provider.DataSource, dname1.Name);
stdio.WriteLine("server2: {0} default database:{1}", Side2.Provider.DataSource, dname2.Name);
if (!Exists(dname1) || !Exists(dname2))
return string.Empty;
StringBuilder builder = new StringBuilder();
builder.AppendFormat("-- sqlcon:", Side1.Provider.DataSource, dname1.Name).AppendLine();
builder.AppendFormat("-- compare server={0} db={1}", Side1.Provider.DataSource, dname1.Name).AppendLine();
builder.AppendFormat("-- server={0} db={1} @ {2}", Side2.Provider.DataSource, dname2.Name, DateTime.Now).AppendLine();
CancelableWork.CanCancel(cts =>
{
foreach (var tname1 in N1)
{
if (cts.IsCancellationRequested)
return;
TableName tname2 = N2.Where(t => t.ShortName == tname1.ShortName).FirstOrDefault();
if (tname2 == null)
{
tname2 = new TableName(dname2, tname1.SchemaName, tname1.ShortName);
}
if (compareType == ActionType.CompareData && cfg.compareExcludedTables.FirstOrDefault(t => t == tname1.Name) != null)
{
stdio.WriteLine("{0} is excluded", tname1);
continue;
}
if (tname2.Exists())
builder.Append(CompareTable(compareType, CompareSideType.compare, tname1, tname2, cfg.PK, exceptColumns));
else
{
if (compareType == ActionType.CompareSchema)
{
string sql = tname1.GenerateCluase();
stdio.WriteLine(sql);
builder.Append(sql);
}
else
{
stdio.WriteLine("{0} doesn't exist", tname2);
}
}
}
});
return builder.ToString();
}