本文整理汇总了C#中RelayTwo.Subset方法的典型用法代码示例。如果您正苦于以下问题:C# RelayTwo.Subset方法的具体用法?C# RelayTwo.Subset怎么用?C# RelayTwo.Subset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RelayTwo
的用法示例。
在下文中一共展示了RelayTwo.Subset方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveSubsetOfDatabase
public void SaveSubsetOfDatabase()
{
{
RelayTwo relay = new RelayTwo();
TableTwo table = relay.CreateTable("Table1");
table.AddField<string>("name");
table.AddField<bool>("1337");
TableRow row1 = table.CreateRow();
TableRow row2 = table.CreateRow();
TableRow row3 = table.CreateRow();
row1.Set("name", "Arne");
row1.Set("1337", false);
row2.Set("name", "Björn");
row2.Set("1337", true);
row3.Set("name", "Charlie");
row3.Set("1337", false);
Assert.AreEqual(3, table.GetRows().Length);
RelayTwo subset = relay.Subset("Table1", (o => o.Get<bool>("1337") == true));
subset.SaveAll("Only1337People.json");
}
{
RelayTwo relay = new RelayTwo("Only1337People.json");
TableTwo table = relay.GetTable("Table1");
TableRow[] rows = table.GetRows();
Assert.AreEqual(1, rows.Length);
Assert.AreEqual("Björn", table.First().Get<string>("name"));
}
}
示例2: MergeSaves
public void MergeSaves()
{
{
RelayTwo relay = new RelayTwo();
TableTwo table = relay.CreateTable("Table");
table.AddField<string>("name");
TableRow row1 = table.CreateRow();
TableRow row2 = table.CreateRow();
TableRow row3 = table.CreateRow();
row1.Set("name", "a");
row2.Set("name", "b");
row3.Set("name", "c");
Assert.AreEqual(3, table.GetRows().Length);
Assert.AreEqual("a", table.GetRow(0).Get<string>("name"));
Assert.AreEqual("b", table.GetRow(1).Get<string>("name"));
Assert.AreEqual("c", table.GetRow(2).Get<string>("name"));
RelayTwo save1 = relay.Subset("Table", (o => o.Get<string>("name") == "a"));
RelayTwo save2 = relay.Subset("Table", (o => o.Get<string>("name") == "b"));
RelayTwo save3 = relay.Subset("Table", (o => o.Get<string>("name") == "c"));
Assert.AreEqual(1, save1.GetTable("Table").GetRows().Length);
Assert.AreEqual(1, save2.GetTable("Table").GetRows().Length);
Assert.AreEqual(1, save3.GetTable("Table").GetRows().Length);
save1.SaveAll("PartialSave1.json");
save2.SaveAll("PartialSave2.json");
save3.SaveAll("PartialSave3.json");
}
{
RelayTwo relay = new RelayTwo();
relay.MergeWith(new RelayTwo("PartialSave1.json"));
relay.MergeWith(new RelayTwo("PartialSave2.json"));
relay.MergeWith(new RelayTwo("PartialSave3.json"));
TableTwo table = relay.GetTable("Table");
Assert.AreEqual(3, table.GetRows().Length);
Assert.AreEqual("a", table.GetRow(0).Get<string>("name"));
Assert.AreEqual("b", table.GetRow(1).Get<string>("name"));
Assert.AreEqual("c", table.GetRow(2).Get<string>("name"));
}
}
示例3: MergeSavesWithDifferentFields
public void MergeSavesWithDifferentFields()
{
{
RelayTwo relay = new RelayTwo();
TableTwo table = relay.CreateTable("Table");
table.AddField<string>("oldField");
TableRow row1 = table.CreateRow();
TableRow row2 = table.CreateRow();
TableRow row3 = table.CreateRow();
row1.Set("oldField", "kottar");
row2.Set("oldField", "stenar");
row3.Set("oldField", "gräs");
relay.Subset("Table", (o => o.row == 0)).SaveAll("s0.json");
relay.Subset("Table", (o => o.row == 1)).SaveAll("s1.json");
relay.Subset("Table", (o => o.row == 2)).SaveAll("s2.json");
table.AddField<int>("newField");
TableRow row4 = table.CreateRow();
TableRow row5 = table.CreateRow();
row4.Set("newField", 500);
row5.Set("newField", 1000);
relay.Subset("Table", (o => o.row == 3)).SaveAll("s3.json");
relay.Subset("Table", (o => o.row == 4)).SaveAll("s4.json");
}
{
RelayTwo relay = new RelayTwo();
relay.MergeWith(new RelayTwo("s4.json"));
relay.MergeWith(new RelayTwo("s0.json"));
relay.MergeWith(new RelayTwo("s1.json"));
relay.MergeWith(new RelayTwo("s2.json"));
relay.MergeWith(new RelayTwo("s3.json"));
TableTwo table = relay.GetTable("Table");
Assert.AreEqual(5, table.GetRows().Length);
Assert.AreEqual("kottar", table.GetRow(0).Get<string>("oldField"));
Assert.AreEqual("stenar", table.GetRow(1).Get<string>("oldField"));
Assert.AreEqual("gräs", table.GetRow(2).Get<string>("oldField"));
Assert.AreEqual(500, table.GetRow(3).Get<int>("newField"));
Assert.AreEqual(1000, table.GetRow(4).Get<int>("newField"));
}
}
示例4: MergeTwoSubsets
public void MergeTwoSubsets()
{
RelayTwo relay = new RelayTwo();
TableTwo table = relay.CreateTable("Table1");
table.AddField<string>("name");
table.AddField<bool>("1337");
TableRow row1 = table.CreateRow();
TableRow row2 = table.CreateRow();
TableRow row3 = table.CreateRow();
row1.Set("name", "Arne");
row1.Set("1337", false);
row2.Set("name", "Björn");
row2.Set("1337", true);
row3.Set("name", "Charlie");
row3.Set("1337", false);
Assert.AreEqual(3, table.GetRows().Length);
RelayTwo subsetA = relay.Subset("Table1", (o => o.Get<bool>("1337") == true));
RelayTwo subsetB = relay.Subset("Table1", (o => o.Get<bool>("1337") == false));
subsetA.MergeWith(subsetB);
Assert.Throws<RelayTwo.RelayMergeException>(() => subsetB.MergeWith(relay));
Assert.AreEqual(true, subsetA.Equals(relay));
Assert.AreEqual(false, subsetB.Equals(relay));
}