本文整理汇总了C#中Z.Test.SingleMany类的典型用法代码示例。如果您正苦于以下问题:C# SingleMany类的具体用法?C# SingleMany怎么用?C# SingleMany使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SingleMany类属于Z.Test命名空间,在下文中一共展示了SingleMany类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestMethod1
public void TestMethod1()
{
Helper.CleanDatabase();
var single1 = new SingleMany {ColumnInt = 1};
var single2 = new SingleMany {ColumnInt = 8};
var single3 = new SingleMany {ColumnInt = 64};
var many1 = new List<SingleMany> {new SingleMany {ColumnInt = 512}, new SingleMany {ColumnInt = 1024}, new SingleMany {ColumnInt = 2048}}; // 3584
var many2 = new List<SingleMany> {new SingleMany {ColumnInt = 4096}, new SingleMany {ColumnInt = 8192}, new SingleMany {ColumnInt = 16384}}; // 28672
var many3 = new List<SingleMany> {new SingleMany {ColumnInt = 32768}, new SingleMany {ColumnInt = 65536}, new SingleMany {ColumnInt = 131072}}; // 229376
Helper.LinkSingleMany(single1, single2, single3, many1, many2, many3);
Helper.InsertFromMetas(new List<string>() {"BulkInsertAll"}, single1, single2, single3, many1, many2, many3);
Helper.UpdateFromMetas(new List<string>() {"BulkInsertAll"}, single1, single2, single3, many1, many2, many3);
using (var cn = Helper.GetConnection())
{
//cn.BulkInsert(many1).ThenBulkInsert(x => x.ColumnInt);
cn.Open();
// PreTest
}
using (var cn = Helper.GetConnection())
{
cn.Open();
// Action
}
// GET count
int columnInt = 0;
int columnUpdateInt = 0;
int columnInt_Key = 0;
int columnUpdateInt_Key = 0;
using (var connection = Helper.GetConnection())
{
connection.Open();
using (var command = connection.CreateCommand())
{
command.CommandText = "SELECT SUM(ColumnInt) FROM SingleMany";
columnInt = Convert.ToInt32(command.ExecuteScalar());
command.CommandText = "SELECT SUM(ColumnUpdateInt) FROM SingleMany";
columnUpdateInt = Convert.ToInt32(command.ExecuteScalar());
command.CommandText = "SELECT SUM(ColumnInt) FROM SingleMany_Key";
columnInt_Key = Convert.ToInt32(command.ExecuteScalar());
command.CommandText = "SELECT SUM(ColumnUpdateInt) FROM SingleMany_Key";
columnUpdateInt_Key = Convert.ToInt32(command.ExecuteScalar());
}
}
}
示例2: Z_Test_0030
public void Z_Test_0030()
{
Helper.CleanDatabase();
var single1 = new SingleMany {ColumnInt = 1};
var single2 = new SingleMany {ColumnInt = 8};
var single3 = new SingleMany {ColumnInt = 64};
var many1 = new List<SingleMany> {new SingleMany {ColumnInt = 512}, new SingleMany {ColumnInt = 1024}, new SingleMany {ColumnInt = 2048}};
var many2 = new List<SingleMany> {new SingleMany {ColumnInt = 4096}, new SingleMany {ColumnInt = 8192}, new SingleMany {ColumnInt = 16384}};
var many3 = new List<SingleMany> {new SingleMany {ColumnInt = 32768}, new SingleMany {ColumnInt = 65536}, new SingleMany {ColumnInt = 131072}};
Helper.LinkSingleMany(single1, single2, single3, many1, many2, many3);
Helper.InsertFromMetas("".Split(';').ToList(), single1, single2, single3, many1, many2, many3);
Helper.UpdateFromMetas("".Split(';').ToList(), single1, single2, single3, many1, many2, many3);
// GET count before
int columnInt_before = 0;
int columnUpdateInt_before = 0;
int columnInt_Key_before = 0;
int columnUpdateInt_Key_before = 0;
using (var connection = Helper.GetConnection())
{
connection.Open();
using (var command = connection.CreateCommand())
{
command.CommandText = "SELECT ISNULL((SELECT SUM(ColumnInt) FROM SingleMany), 0)";
columnInt_before = Convert.ToInt32(command.ExecuteScalar());
command.CommandText = "SELECT ISNULL((SELECT SUM(ColumnUpdateInt) FROM SingleMany), 0)";
columnUpdateInt_before = Convert.ToInt32(command.ExecuteScalar());
command.CommandText = "SELECT ISNULL((SELECT SUM(ColumnInt) FROM SingleMany_Key), 0)";
columnInt_Key_before = Convert.ToInt32(command.ExecuteScalar());
command.CommandText = "SELECT ISNULL((SELECT SUM(ColumnUpdateInt) FROM SingleMany_Key), 0)";
columnUpdateInt_Key_before = Convert.ToInt32(command.ExecuteScalar());
}
}
using (var cn = Helper.GetConnection())
{
cn.Open();
// PreTest
// Action
cn.BulkInsert("key", many1, x => x.Single1, x => x.Single2, x => x.Single3);
}
// GET count
int columnInt = 0;
int columnUpdateInt = 0;
int columnInt_Key = 0;
int columnUpdateInt_Key = 0;
using (var connection = Helper.GetConnection())
{
connection.Open();
using (var command = connection.CreateCommand())
{
command.CommandText = "SELECT ISNULL((SELECT SUM(ColumnInt) FROM SingleMany), 0)";
columnInt = Convert.ToInt32(command.ExecuteScalar());
command.CommandText = "SELECT ISNULL((SELECT SUM(ColumnUpdateInt) FROM SingleMany), 0)";
columnUpdateInt = Convert.ToInt32(command.ExecuteScalar());
command.CommandText = "SELECT ISNULL((SELECT SUM(ColumnInt) FROM SingleMany_Key), 0)";
columnInt_Key = Convert.ToInt32(command.ExecuteScalar());
command.CommandText = "SELECT ISNULL((SELECT SUM(ColumnUpdateInt) FROM SingleMany_Key), 0)";
columnUpdateInt_Key = Convert.ToInt32(command.ExecuteScalar());
}
}
// Test
Assert.AreEqual(0, columnInt);
Assert.AreEqual(0, columnUpdateInt);
Assert.AreEqual(many1.Sum(x => x.ColumnInt) + many1.Sum(x => x.Single1.ColumnInt) + many1.Sum(x => x.Single2.ColumnInt) + many1.Sum(x => x.Single3.ColumnInt), columnInt_Key);
Assert.AreEqual(0, columnUpdateInt_Key);
}
示例3: Z_Test_0147
public async Task Z_Test_0147()
{
Helper.CleanDatabase();
var single1 = new SingleMany {ColumnInt = 1};
var single2 = new SingleMany {ColumnInt = 8};
var single3 = new SingleMany {ColumnInt = 64};
var many1 = new List<SingleMany> {new SingleMany {ColumnInt = 512}, new SingleMany {ColumnInt = 1024}, new SingleMany {ColumnInt = 2048}};
var many2 = new List<SingleMany> {new SingleMany {ColumnInt = 4096}, new SingleMany {ColumnInt = 8192}, new SingleMany {ColumnInt = 16384}};
var many3 = new List<SingleMany> {new SingleMany {ColumnInt = 32768}, new SingleMany {ColumnInt = 65536}, new SingleMany {ColumnInt = 131072}};
Helper.LinkSingleMany(single1, single2, single3, many1, many2, many3);
Helper.InsertFromMetas("BulkInsert2;BulkInsert3;UpdateValue2;UpdateValue3".Split(';').ToList(), single1, single2, single3, many1, many2, many3);
Helper.UpdateFromMetas("BulkInsert2;BulkInsert3;UpdateValue2;UpdateValue3".Split(';').ToList(), single1, single2, single3, many1, many2, many3);
// GET count before
int columnInt_before = 0;
int columnUpdateInt_before = 0;
int columnInt_Key_before = 0;
int columnUpdateInt_Key_before = 0;
using (var connection = Helper.GetConnection())
{
connection.Open();
using (var command = connection.CreateCommand())
{
command.CommandText = "SELECT ISNULL((SELECT SUM(ColumnInt) FROM SingleMany), 0)";
columnInt_before = Convert.ToInt32(command.ExecuteScalar());
command.CommandText = "SELECT ISNULL((SELECT SUM(ColumnUpdateInt) FROM SingleMany), 0)";
columnUpdateInt_before = Convert.ToInt32(command.ExecuteScalar());
command.CommandText = "SELECT ISNULL((SELECT SUM(ColumnInt) FROM SingleMany_Key), 0)";
columnInt_Key_before = Convert.ToInt32(command.ExecuteScalar());
command.CommandText = "SELECT ISNULL((SELECT SUM(ColumnUpdateInt) FROM SingleMany_Key), 0)";
columnUpdateInt_Key_before = Convert.ToInt32(command.ExecuteScalar());
}
}
using (var cn = Helper.GetConnection())
{
cn.Open();
// PreTest
// Action
await cn.BulkActionAsync(action => action.BulkMerge(single1, single2, single3));
}
// GET count
int columnInt = 0;
int columnUpdateInt = 0;
int columnInt_Key = 0;
int columnUpdateInt_Key = 0;
using (var connection = Helper.GetConnection())
{
connection.Open();
using (var command = connection.CreateCommand())
{
command.CommandText = "SELECT ISNULL((SELECT SUM(ColumnInt) FROM SingleMany), 0)";
columnInt = Convert.ToInt32(command.ExecuteScalar());
command.CommandText = "SELECT ISNULL((SELECT SUM(ColumnUpdateInt) FROM SingleMany), 0)";
columnUpdateInt = Convert.ToInt32(command.ExecuteScalar());
command.CommandText = "SELECT ISNULL((SELECT SUM(ColumnInt) FROM SingleMany_Key), 0)";
columnInt_Key = Convert.ToInt32(command.ExecuteScalar());
command.CommandText = "SELECT ISNULL((SELECT SUM(ColumnUpdateInt) FROM SingleMany_Key), 0)";
columnUpdateInt_Key = Convert.ToInt32(command.ExecuteScalar());
}
}
// Test
Assert.AreEqual(columnInt_before + single1.ColumnInt, columnInt);
Assert.AreEqual(single2.ColumnInt + single3.ColumnInt, columnUpdateInt);
Assert.AreEqual(columnInt_Key_before, columnInt_Key);
Assert.AreEqual(columnUpdateInt_Key_before, columnUpdateInt_Key);
}
示例4: InsertFromMetas
public static void InsertFromMetas(List<string> metas, SingleMany single1, SingleMany single2, SingleMany single3, List<SingleMany> many1, List<SingleMany> many2, List<SingleMany> many3)
{
var count = 0;
if (metas.Contains("BulkInsertAll") || metas.Contains("BulkInsert1"))
{
using (var connection = GetConnection())
{
connection.Open();
var list = new List<SingleMany>();
list.Add(single1);
list.AddRange(many1);
list.AddRange(many1.Select(x => x.Single1));
list.AddRange(many2.Select(x => x.Single1));
list.AddRange(many3.Select(x => x.Single1));
list.AddRange(many1.SelectMany(y => y.Many1));
list.AddRange(many2.SelectMany(y => y.Many1));
list.AddRange(many3.SelectMany(y => y.Many1));
connection.BulkInsert(list);
connection.BulkInsert("key", list);
}
count += single1.ColumnInt + many1.Sum(x => x.ColumnInt);
}
if (metas.Contains("BulkInsertAll") || metas.Contains("BulkInsert2"))
{
using (var connection = GetConnection())
{
connection.Open();
//connection.BulkInsert(single2).BulkInsert(many2)
// .AlsoBulkInsert(x => x.Single1).AlsoBulkInsert(x => x.Single2).AlsoBulkInsert(x => x.Single3)
// .AlsoBulkInsert(x => x.Many1).AlsoBulkInsert(x => x.Many2).AlsoBulkInsert(x => x.Many3);
//connection.BulkInsert("key", single2).BulkInsert("key", many2)
//.AlsoBulkInsert("key", x => x.Single1).AlsoBulkInsert("key", x => x.Single2).AlsoBulkInsert("key", x => x.Single3)
//.AlsoBulkInsert("key", x => x.Many1).AlsoBulkInsert("key", x => x.Many2).AlsoBulkInsert("key", x => x.Many3);
var list = new List<SingleMany>();
list.Add(single2);
list.AddRange(many2);
list.AddRange(many1.Select(x => x.Single2));
list.AddRange(many2.Select(x => x.Single2));
list.AddRange(many3.Select(x => x.Single2));
list.AddRange(many1.SelectMany(y => y.Many2));
list.AddRange(many2.SelectMany(y => y.Many2));
list.AddRange(many3.SelectMany(y => y.Many2));
connection.BulkInsert(list);
connection.BulkInsert("key", list);
}
count += single2.ColumnInt + many2.Sum(x => x.ColumnInt);
}
if (metas.Contains("BulkInsertAll") || metas.Contains("BulkInsert3"))
{
using (var connection = GetConnection())
{
connection.Open();
//connection.BulkInsert(single3).BulkInsert(many3)
// .AlsoBulkInsert(x => x.Single1).AlsoBulkInsert(x => x.Single2).AlsoBulkInsert(x => x.Single3)
// .AlsoBulkInsert(x => x.Many1).AlsoBulkInsert(x => x.Many2).AlsoBulkInsert(x => x.Many3);
//connection.BulkInsert("key", single3).BulkInsert("key", many3)
//.AlsoBulkInsert("key", x => x.Single1).AlsoBulkInsert("key", x => x.Single2).AlsoBulkInsert("key", x => x.Single3)
//.AlsoBulkInsert("key", x => x.Many1).AlsoBulkInsert("key", x => x.Many2).AlsoBulkInsert("key", x => x.Many3);
//
var list = new List<SingleMany>();
list.Add(single3);
list.AddRange(many3);
list.AddRange(many1.Select(x => x.Single3));
list.AddRange(many2.Select(x => x.Single3));
list.AddRange(many3.Select(x => x.Single3));
list.AddRange(many1.SelectMany(y => y.Many3));
list.AddRange(many2.SelectMany(y => y.Many3));
list.AddRange(many3.SelectMany(y => y.Many3));
connection.BulkInsert(list);
connection.BulkInsert("key", list);
}
count += single3.ColumnInt + many3.Sum(x => x.ColumnInt);
}
//using (var connection = GetConnection())
//{
// connection.Open();
// using (var command = connection.CreateCommand())
// {
// command.CommandText = "SELECT ISNULL((SELECT SUM(ColumnInt) FROM SingleMany), 0)";
// Assert.AreEqual(count, Convert.ToInt32(command.ExecuteScalar()));
// command.CommandText = "SELECT ISNULL((SELECT SUM(ColumnInt) FROM SingleMany_Key), 0)";
// Assert.AreEqual(count, Convert.ToInt32(command.ExecuteScalar()));
// }
//}
}
示例5: UpdateFromMetas
public static void UpdateFromMetas(List<string> metas, SingleMany single1, SingleMany single2, SingleMany single3, List<SingleMany> many1, List<SingleMany> many2, List<SingleMany> many3)
{
if (metas.Contains("UpdateValueAll") || metas.Contains("UpdateValue1"))
{
single1.ColumnUpdateInt = single1.ColumnInt;
many1.ForEach(x => x.ColumnUpdateInt = x.ColumnInt);
many1.ForEach(x => x.Many1.ForEach(y => y.ColumnUpdateInt = y.ColumnInt));
many2.ForEach(x => x.Many1.ForEach(y => y.ColumnUpdateInt = y.ColumnInt));
many3.ForEach(x => x.Many1.ForEach(y => y.ColumnUpdateInt = y.ColumnInt));
many1.ForEach(x => x.Single1.ColumnUpdateInt = x.Single1.ColumnInt);
many2.ForEach(x => x.Single1.ColumnUpdateInt = x.Single1.ColumnInt);
many3.ForEach(x => x.Single1.ColumnUpdateInt = x.Single1.ColumnInt);
}
if (metas.Contains("UpdateValueAll") || metas.Contains("UpdateValue2"))
{
single2.ColumnUpdateInt = single2.ColumnInt;
many2.ForEach(x => x.ColumnUpdateInt = x.ColumnInt);
many1.ForEach(x => x.Many2.ForEach(y => y.ColumnUpdateInt = y.ColumnInt));
many2.ForEach(x => x.Many2.ForEach(y => y.ColumnUpdateInt = y.ColumnInt));
many3.ForEach(x => x.Many2.ForEach(y => y.ColumnUpdateInt = y.ColumnInt));
many1.ForEach(x => x.Single2.ColumnUpdateInt = x.Single2.ColumnInt);
many2.ForEach(x => x.Single2.ColumnUpdateInt = x.Single2.ColumnInt);
many3.ForEach(x => x.Single2.ColumnUpdateInt = x.Single2.ColumnInt);
}
if (metas.Contains("UpdateValueAll") || metas.Contains("UpdateValue3"))
{
single3.ColumnUpdateInt = single3.ColumnInt;
many3.ForEach(x => x.ColumnUpdateInt = x.ColumnInt);
many1.ForEach(x => x.Many3.ForEach(y => y.ColumnUpdateInt = y.ColumnInt));
many2.ForEach(x => x.Many3.ForEach(y => y.ColumnUpdateInt = y.ColumnInt));
many3.ForEach(x => x.Many3.ForEach(y => y.ColumnUpdateInt = y.ColumnInt));
many1.ForEach(x => x.Single3.ColumnUpdateInt = x.Single3.ColumnInt);
many2.ForEach(x => x.Single3.ColumnUpdateInt = x.Single3.ColumnInt);
many3.ForEach(x => x.Single3.ColumnUpdateInt = x.Single3.ColumnInt);
}
}
示例6: LinkSingleMany
public static void LinkSingleMany(SingleMany single1, SingleMany single2, SingleMany single3, List<SingleMany> many1, List<SingleMany> many2, List<SingleMany> many3)
{
single1.Single1 = single1;
single1.Single2 = single2;
single1.Single3 = single3;
single2.Single1 = single1;
single2.Single2 = single2;
single2.Single3 = single3;
single3.Single1 = single1;
single3.Single2 = single2;
single3.Single3 = single3;
single1.Many1 = many1;
single1.Many2 = many2;
single1.Many3 = many3;
single2.Many1 = many1;
single2.Many2 = many2;
single2.Many3 = many3;
single3.Many1 = many1;
single3.Many2 = many2;
single3.Many3 = many3;
many1.ForEach(x => x.Single1 = new SingleMany {ColumnInt = single1.ColumnInt});
many1.ForEach(x => x.Single2 = new SingleMany {ColumnInt = single2.ColumnInt});
many1.ForEach(x => x.Single3 = new SingleMany {ColumnInt = single3.ColumnInt});
many2.ForEach(x => x.Single1 = new SingleMany {ColumnInt = single1.ColumnInt});
many2.ForEach(x => x.Single2 = new SingleMany {ColumnInt = single2.ColumnInt});
many2.ForEach(x => x.Single3 = new SingleMany {ColumnInt = single3.ColumnInt});
many3.ForEach(x => x.Single1 = new SingleMany {ColumnInt = single1.ColumnInt});
many3.ForEach(x => x.Single2 = new SingleMany {ColumnInt = single2.ColumnInt});
many3.ForEach(x => x.Single3 = new SingleMany {ColumnInt = single3.ColumnInt});
many1.ForEach(x => x.Many1 = new List<SingleMany> {new SingleMany {ColumnInt = single1.ColumnInt}});
many1.ForEach(x => x.Many2 = new List<SingleMany> {new SingleMany {ColumnInt = single2.ColumnInt}});
many1.ForEach(x => x.Many3 = new List<SingleMany> {new SingleMany {ColumnInt = single3.ColumnInt}});
many2.ForEach(x => x.Many1 = new List<SingleMany> {new SingleMany {ColumnInt = single1.ColumnInt}});
many2.ForEach(x => x.Many2 = new List<SingleMany> {new SingleMany {ColumnInt = single2.ColumnInt}});
many2.ForEach(x => x.Many3 = new List<SingleMany> {new SingleMany {ColumnInt = single3.ColumnInt}});
many3.ForEach(x => x.Many1 = new List<SingleMany> {new SingleMany {ColumnInt = single1.ColumnInt}});
many3.ForEach(x => x.Many2 = new List<SingleMany> {new SingleMany {ColumnInt = single2.ColumnInt}});
many3.ForEach(x => x.Many3 = new List<SingleMany> {new SingleMany {ColumnInt = single3.ColumnInt}});
//many1.ForEach(x => x.Many1 = new List<SingleMany>() {new SingleMany() {ColumnInt = 262576}});
//many1.ForEach(x => x.Many2 = new List<SingleMany>() {new SingleMany() {ColumnInt = 525152}});
//many1.ForEach(x => x.Many3 = new List<SingleMany>() {new SingleMany() {ColumnInt = 1050304}});
//many2.ForEach(x => x.Many1 = new List<SingleMany>() {new SingleMany() {ColumnInt = 2100608}});
//many2.ForEach(x => x.Many2 = new List<SingleMany>() {new SingleMany() {ColumnInt = 4201216}});
//many2.ForEach(x => x.Many3 = new List<SingleMany>() {new SingleMany() {ColumnInt = 8402432}});
//many3.ForEach(x => x.Many1 = new List<SingleMany>() {new SingleMany() {ColumnInt = 16804864}});
//many3.ForEach(x => x.Many2 = new List<SingleMany>() {new SingleMany() {ColumnInt = 33609728}});
//many3.ForEach(x => x.Many3 = new List<SingleMany>() {new SingleMany() {ColumnInt = 67219456}});
//many1.ForEach(x => x.Single1 = new SingleMany() {ColumnInt = 1});
//many1.ForEach(x => x.Single2 = new SingleMany() {ColumnInt = 2});
//many1.ForEach(x => x.Single3 = new SingleMany() {ColumnInt = 3});
//many2.ForEach(x => x.Single1 = new SingleMany() {ColumnInt = 4});
//many2.ForEach(x => x.Single2 = new SingleMany() {ColumnInt = 5});
//many2.ForEach(x => x.Single3 = new SingleMany() {ColumnInt = 6});
//many3.ForEach(x => x.Single1 = new SingleMany() {ColumnInt = 7});
//many3.ForEach(x => x.Single2 = new SingleMany() {ColumnInt = 8});
//many3.ForEach(x => x.Single3 = new SingleMany() {ColumnInt = 9});
}