本文整理汇总了C#中Seed.CreateTable方法的典型用法代码示例。如果您正苦于以下问题:C# Seed.CreateTable方法的具体用法?C# Seed.CreateTable怎么用?C# Seed.CreateTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Seed
的用法示例。
在下文中一共展示了Seed.CreateTable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: before_each
void before_each()
{
seed = new Seed();
books = new Books();
seed.PurgeDb();
seed.CreateTable("Books",
seed.Id(),
new { Title = "nvarchar(255)" }).ExecuteNonQuery();
seed.CreateTable("Chapters",
seed.Id(),
new { BookId = "int" },
new { Name = "nvarchar(255)" }).ExecuteNonQuery();
book1Id = new { Title = "book 1" }.InsertInto("Books");
new { BookId = book1Id, Name = "Chapter 1" }.InsertInto("Chapters");
new { BookId = book1Id, Name = "Chapter 2" }.InsertInto("Chapters");
book2Id = new { Title = "book 2" }.InsertInto("Books");
new { BookId = book2Id, Name = "Chapter 1" }.InsertInto("Chapters");
new { BookId = book2Id, Name = "Chapter 2" }.InsertInto("Chapters");
}
示例2: specify_db_can_be_specified
void specify_db_can_be_specified()
{
var connectionString = ConfigurationManager.ConnectionStrings["AnotherDb"].ConnectionString;
seed = new Seed(new ConnectionProfile
{
ConnectionString = connectionString
});
seed.PurgeDb();
seed.CreateTable("Authors",
seed.Id(),
new { Name = "nvarchar(255)" }
).ExecuteNonQuery(seed.ConnectionProfile);
seed.CreateTable("Emails",
seed.Id(),
new { AuthorId = "int" },
new { Address = "nvarchar(255)" }
).ExecuteNonQuery(seed.ConnectionProfile);
db = new DynamicDb(connectionString);
var authorId = db.Authors().Insert(new { Name = "hello" });
db.Emails().Insert(new { authorId, Address = "[email protected]" });
(db.Authors().All().First().Email().Address as string).should_be("[email protected]");
}
示例3: before_each
void before_each()
{
seed = new Seed();
markets = new Markets();
seed.PurgeDb();
seed.CreateTable("Markets",
seed.Id(),
new { Name = "nvarchar(255)" }).ExecuteNonQuery();
seed.CreateTable("SupplyChains",
seed.Id(),
new { MarketId = "int" },
new { SupplierId = "int" }).ExecuteNonQuery();
seed.CreateTable("Suppliers",
seed.Id(),
new { Name = "nvarchar(255)" }).ExecuteNonQuery();
supplier1Id = new { Name = "Supplier 1" }.InsertInto("Suppliers");
supplier2Id = new { Name = "Supplier 2" }.InsertInto("Suppliers");
market1Id = new { Name = "Market 1" }.InsertInto("Markets");
market2Id = new { Name = "Market 2" }.InsertInto("Markets");
new { MarketId = market1Id, SupplierId = supplier1Id }.InsertInto("SupplyChains");
new { MarketId = market2Id, SupplierId = supplier1Id }.InsertInto("SupplyChains");
}
示例4: before_each
void before_each()
{
seed = new Seed();
seed.PurgeDb();
cars = new Cars();
seed.CreateTable("Cars",
new { Id = "int" },
new { Model = "nvarchar(255)" }).ExecuteNonQuery();
seed.CreateTable("BluePrints",
new { Id = "int" },
new { CarId = "int" },
new { Sku = "nvarchar(255)" }).ExecuteNonQuery();
car1Id = 100;
new { Id = car1Id, Model = "car 1" }.InsertInto("Cars");
car2Id = 200;
new { Id = car2Id, Model = "car 2" }.InsertInto("Cars");
bluePrint1Id = 300;
new { Id = bluePrint1Id, CarId = car1Id, Sku = "Sku 1" }.InsertInto("BluePrints");
bluePrint2Id = 400;
new { Id = bluePrint2Id, CarId = car2Id, Sku = "Sku 2" }.InsertInto("BluePrints");
}
示例5: describe_db_rows_to_json
void describe_db_rows_to_json()
{
before = () =>
{
Seed seed = new Seed();
seed.PurgeDb();
seed.CreateTable("Rabbits", seed.Id(), new { Name = "nvarchar(255)" }).ExecuteNonQuery();
seed.CreateTable("Tasks",
seed.Id(),
new { Description = "nvarchar(255)" },
new { RabbitId = "int" },
new { DueDate = "datetime" }).ExecuteNonQuery();
var rabbitId = new { Name = "Yours Truly" }.InsertInto("Rabbits");
new { rabbitId, Description = "bolt onto vans", DueDate = new DateTime(2013, 1, 14) }.InsertInto("Tasks");
rabbitId = new { Name = "Hiro Protaganist" }.InsertInto("Rabbits");
new { rabbitId, Description = "save the world", DueDate = new DateTime(2013, 1, 14) }.InsertInto("Tasks");
new { rabbitId, Description = "deliver pizza", DueDate = new DateTime(2013, 1, 14) }.InsertInto("Tasks");
rabbitId = new { Name = "Lots" }.InsertInto("Rabbits");
for (int i = 0; i < 10; i++)
{
new
{
rabbitId,
Description = "Task: " + i.ToString(),
DueDate = new DateTime(2013, 1, 14)
}.InsertInto("Tasks");
}
};
it["disregards self referencing objects"] = () =>
{
var results = tasks.All().Include("Rabbits").ToList();
(results as IEnumerable<dynamic>).ForEach(s =>
{
s.Rabbit = s.Rabbit();
});
objectToConvert = new Gemini(new { Tasks = results });
string expected = @"{ ""tasks"": [ { ""id"": 1, ""description"": ""bolt onto vans"", ""rabbitId"": 1, ""dueDate"": ""1/14/13 12:00:00 AM"", ""rabbit"": { ""id"": 1, ""name"": ""Yours Truly"" } }, { ""id"": 2, ""description"": ""save the world"", ""rabbitId"": 2, ""dueDate"": ""1/14/13 12:00:00 AM"", ""rabbit"": { ""id"": 2, ""name"": ""Hiro Protaganist"" } }, { ""id"": 3, ""description"": ""deliver pizza"", ""rabbitId"": 2, ""dueDate"": ""1/14/13 12:00:00 AM"", ""rabbit"": { ""id"": 2, ""name"": ""Hiro Protaganist"" } }, { ""id"": 4, ""description"": ""Task: 0"", ""rabbitId"": 3, ""dueDate"": ""1/14/13 12:00:00 AM"", ""rabbit"": { ""id"": 3, ""name"": ""Lots"" } }, { ""id"": 5, ""description"": ""Task: 1"", ""rabbitId"": 3, ""dueDate"": ""1/14/13 12:00:00 AM"", ""rabbit"": { ""id"": 3, ""name"": ""Lots"" } }, { ""id"": 6, ""description"": ""Task: 2"", ""rabbitId"": 3, ""dueDate"": ""1/14/13 12:00:00 AM"", ""rabbit"": { ""id"": 3, ""name"": ""Lots"" } }, { ""id"": 7, ""description"": ""Task: 3"", ""rabbitId"": 3, ""dueDate"": ""1/14/13 12:00:00 AM"", ""rabbit"": { ""id"": 3, ""name"": ""Lots"" } }, { ""id"": 8, ""description"": ""Task: 4"", ""rabbitId"": 3, ""dueDate"": ""1/14/13 12:00:00 AM"", ""rabbit"": { ""id"": 3, ""name"": ""Lots"" } }, { ""id"": 9, ""description"": ""Task: 5"", ""rabbitId"": 3, ""dueDate"": ""1/14/13 12:00:00 AM"", ""rabbit"": { ""id"": 3, ""name"": ""Lots"" } }, { ""id"": 10, ""description"": ""Task: 6"", ""rabbitId"": 3, ""dueDate"": ""1/14/13 12:00:00 AM"", ""rabbit"": { ""id"": 3, ""name"": ""Lots"" } }, { ""id"": 11, ""description"": ""Task: 7"", ""rabbitId"": 3, ""dueDate"": ""1/14/13 12:00:00 AM"", ""rabbit"": { ""id"": 3, ""name"": ""Lots"" } }, { ""id"": 12, ""description"": ""Task: 8"", ""rabbitId"": 3, ""dueDate"": ""1/14/13 12:00:00 AM"", ""rabbit"": { ""id"": 3, ""name"": ""Lots"" } }, { ""id"": 13, ""description"": ""Task: 9"", ""rabbitId"": 3, ""dueDate"": ""1/14/13 12:00:00 AM"", ""rabbit"": { ""id"": 3, ""name"": ""Lots"" } } ] }";
jsonString = DynamicToJson.Convert(objectToConvert);
jsonString.should_be(expected);
};
}
示例6: before_each
void before_each()
{
seed = new Seed();
seed.PurgeDb();
agents = new Agents();
seed.CreateTable("Booths",
seed.Id(),
new { BoothId = "int" },
new { Name = "nvarchar(255)" }).ExecuteNonQuery();
seed.CreateTable("Agents",
new { Id = "int" },
new { BoothId = "int" },
new { Name = "nvarchar(255)" }).ExecuteNonQuery();
new { BoothId = 500, Name = "Booth 500" }.InsertInto("Booths");
new { BoothId = 500, Name = "Agent 1" }.InsertInto("Agents");
}
示例7: associations_can_be_added_directly_to_gemini
void associations_can_be_added_directly_to_gemini()
{
before = () =>
{
comments = new Comments();
seed = new Seed();
seed.PurgeDb();
seed.CreateTable("Blogs", new dynamic[]
{
new { Id = "int", Identity = true, PrimaryKey = true },
new { Title = "nvarchar(255)" },
new { Body = "nvarchar(max)" }
}).ExecuteNonQuery();
seed.CreateTable("Comments", new dynamic[]
{
new { Id = "int", Identity = true, PrimaryKey = true },
new { BlogId = "int", ForeignKey = "Blogs(Id)" },
new { Text = "nvarchar(1000)" }
}).ExecuteNonQuery();
blogId = new { Title = "Some Blog", Body = "Lorem Ipsum" }.InsertInto("Blogs");
commentId = new { BlogId = blogId, Text = "Comment 1" }.InsertInto("Comments");
};
it["change tracking methods exist when changes is mixed in"] = () =>
{
act = () => comment = comments.Single(commentId);
it["returns blog associated with comment"] = () =>
{
(comment.Blog().Id as object).should_be(blogId as object);
};
};
}
示例8: before_each
void before_each()
{
inventory = new Inventory();
seed = new Seed();
seed.PurgeDb();
seed.CreateTable("Inventory", new dynamic[]
{
new { Id = "int", Identity = true, PrimaryKey = true },
new { Sku = "nvarchar(255)" }
}).ExecuteNonQuery();
}
示例9: CreateSchema
public static void CreateSchema(Seed seed)
{
seed.PurgeDb();
seed.CreateTable("Players", new dynamic[]
{
new { Id = "int", Identity = true, PrimaryKey = true },
new { Name = "nvarchar(255)" }
}).ExecuteNonQuery();
seed.CreateTable("Games", new dynamic[]
{
new { Id = "int", Identity = true, PrimaryKey = true },
new { Title = "nvarchar(255)" }
}).ExecuteNonQuery();
seed.CreateTable("Library", new dynamic[]
{
new { Id = "int", Identity = true, PrimaryKey = true },
new { PlayerId = "int" },
new { GameId = "int" },
}).ExecuteNonQuery();
}
示例10: before_each
void before_each()
{
seed = new Seed();
stores = new Stores();
seed.PurgeDb();
seed.CreateTable("Stores", new dynamic[] {
new { Id = "int", Identity = true, PrimaryKey = true },
new { Name = "nvarchar(255)" },
}).ExecuteNonQuery();
seed.CreateTable("DistributionChannels", new dynamic[] {
new { Id = "int", Identity = true, PrimaryKey = true },
new { StoreId = "int" },
new { WarehouseId = "int" }
}).ExecuteNonQuery();
seed.CreateTable("Warehouses", new dynamic[] {
new { Id = "int", Identity = true, PrimaryKey = true },
new { Location = "nvarchar(max)" },
}).ExecuteNonQuery();
storeId = new { Name = "Store 1" }.InsertInto("Stores");
storeId2 = new { Name = "Store 2" }.InsertInto("Stores");
warehouseId = new { Location = "LOC112" }.InsertInto("Warehouses");
warehouseId2 = new { Location = "LOC333" }.InsertInto("Warehouses");
new { StoreId = storeId, WarehouseId = warehouseId }.InsertInto("DistributionChannels");
new { StoreId = storeId2, WarehouseId = warehouseId2 }.InsertInto("DistributionChannels");
}
示例11: describe_db_rows_to_json
void describe_db_rows_to_json()
{
before = () =>
{
Seed seed = new Seed();
seed.PurgeDb();
seed.CreateTable("Rabbits", seed.Id(), new { Name = "nvarchar(255)" }).ExecuteNonQuery();
seed.CreateTable("Tasks", seed.Id(), new { Description = "nvarchar(255)" }, new { RabbitId = "int" }).ExecuteNonQuery();
var rabbitId = new { Name = "YT" }.InsertInto("Rabbits");
var taskId = new { Description = "bolt onto vans", rabbitId }.InsertInto("Tasks");
new { Description = "save the world", rabbitId }.InsertInto("Tasks");
};
it["disregards self referencing objects"] = () =>
{
var results = tasks.All().Include("Rabbits").ToList();
(results as IEnumerable<dynamic>).ForEach(s =>
{
s.Rabbit = s.Rabbit();
});
dynamic newGemini = new Gemini(new { Tasks = results });
string jsonString = DynamicToJson.Convert(newGemini);
jsonString.should_be(@"{ ""Tasks"": [ { ""Id"": 1, ""Description"": ""bolt onto vans"", ""RabbitId"": 1, ""Rabbit"": { ""Id"": 1, ""Name"": ""YT"", ""Task"": [ { ""Id"": 2, ""Description"": ""save the world"", ""RabbitId"": 1 } ] } } ] }");
};
}
示例12: before_each
void before_each()
{
seed = new Seed();
records = new Records();
seed.PurgeDb();
seed.CreateTable("Records", new dynamic[]
{
new { Id = "int" },
new { Name = "nvarchar(255)" }
}).ExecuteNonQuery();
seed.CreateTable("OtherRecords", new dynamic[]
{
new { Id = "int" },
new { RecordId = "int" },
new { Name2 = "nvarchar(255)" }
}).ExecuteNonQuery();
new string[]
{
"Record 100", "Record 101",
"Record 102", "Record 103",
"Record 104", "Record 105",
"Record 106", "Record 107",
"Record 108", "Record 109",
"Record 201", "Record 202",
"Record 203", "Record 204",
"Record 205", "Record 206",
"Record 207", "Record 208",
"Record 209", "Record 200"
}.ForEach(s => new
{
Id = int.Parse(s.Replace("Record ", "")),
Name = s
}.InsertInto("Records"));
new string[]
{
"Record 30100", "Record 30101",
"Record 30102", "Record 30103",
"Record 30104", "Record 30105",
"Record 30106", "Record 30107",
"Record 30108", "Record 30109",
"Record 40201", "Record 40202",
"Record 40203", "Record 40204",
"Record 40205", "Record 40206",
"Record 40207", "Record 40208",
"Record 40209", "Record 40200"
}.ForEach(s => new
{
Id = int.Parse(s.Replace("Record ","")),
RecordId = int.Parse(
s.Replace("Record ","")
.Replace("30", "")
.Replace("40","")),
Name2 = s
}.InsertInto("OtherRecords"));
}
示例13: saving_dynamic_params
void saving_dynamic_params()
{
before = () =>
{
seed = new Seed();
seed.PurgeDb();
seed.CreateTable("Blogs", new dynamic[]
{
new { Id = "int", Identity = true, PrimaryKey = true },
new { Title = "nvarchar(255)" }
}).ExecuteNonQuery();
nameValueCollection.Add("Title", "Some Title");
};
it["persists saveable values to the database"] = () =>
{
var blogs = new DynamicRepository("Blogs");
var blogId = blogs.Insert(asDynamic);
var blog = blogs.Single(blogId);
(blog.Title as string).should_be("Some Title");
};
}
示例14: mass_assignment
void mass_assignment()
{
before = () =>
{
seed = new Seed();
seed.PurgeDb();
seed.CreateTable("Users", new dynamic[]
{
new { Id = "int", Identity = true, PrimaryKey = true },
new { Name = "nvarchar(255)" },
new { IsAdmin = "bit", Default = false }
}).ExecuteNonQuery();
nameValueCollection.Add("Name", "John");
nameValueCollection.Add("IsAdmin", "true");
};
it["allows the ability to exclude fields"] = () =>
{
var users = new DynamicRepository("Users");
var userId = users.Insert(asDynamic.Exclude("IsAdmin"));
var user = users.Single(userId);
(user.Name as string).should_be("John");
((bool)user.IsAdmin).should_be(false);
};
it["allows the ability to select fields"] = () =>
{
var users = new DynamicRepository("Users");
var userId = users.Insert(asDynamic.Select("Name"));
var user = users.Single(userId);
(user.Name as string).should_be("John");
((bool)user.IsAdmin).should_be(false);
};
}
示例15: describe_track_back_property
void describe_track_back_property()
{
before = () =>
{
Seed seed = new Seed();
seed.PurgeDb();
seed.CreateTable("Rabbits", seed.Id(), new { Name = "nvarchar(255)" }).ExecuteNonQuery();
seed.CreateTable("Tasks", seed.Id(), new { Description = "nvarchar(255)" }, new { RabbitId = "int" }).ExecuteNonQuery();
rabbitId = new { Name = "YT" }.InsertInto("Rabbits");
task1Id = new { Description = "task 1", rabbitId }.InsertInto("Tasks");
task2Id = new { Description = "task 2", rabbitId }.InsertInto("Tasks");
task3Id = new { Description = "task 3", rabbitId }.InsertInto("Tasks");
};
it["tracks back to multiple instances, converting a single value to a collection"] = () =>
{
var allTasks = tasks.All().Include("Rabbit") as DynamicModels;
var task = allTasks.First();
(task.Rabbit().Task as List<dynamic>).Count.should_be(3);
(task.Rabbit().Task as List<dynamic>).should_contain(allTasks.First() as object);
(task.Rabbit().Task as List<dynamic>).should_contain(allTasks.Second() as object);
(task.Rabbit().Task as List<dynamic>).should_contain(allTasks.Last() as object);
};
}