本文整理汇总了C#中ModificationCommandTreeGenerator.GenerateInsert方法的典型用法代码示例。如果您正苦于以下问题:C# ModificationCommandTreeGenerator.GenerateInsert方法的具体用法?C# ModificationCommandTreeGenerator.GenerateInsert怎么用?C# ModificationCommandTreeGenerator.GenerateInsert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModificationCommandTreeGenerator
的用法示例。
在下文中一共展示了ModificationCommandTreeGenerator.GenerateInsert方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Can_convert_insert_command_trees_when_table_splitting
public void Can_convert_insert_command_trees_when_table_splitting()
{
var model = TestContext.CreateDynamicUpdateModel();
var modificationFunctionMapping
= TestContext.GetModificationFunctionMapping("JobTask");
var converter
= new DynamicToFunctionModificationCommandConverter(
modificationFunctionMapping.Item1, modificationFunctionMapping.Item2);
var modificationCommandTreeGenerator
= new ModificationCommandTreeGenerator(model);
var commandTrees
= modificationCommandTreeGenerator
.GenerateInsert(modificationFunctionMapping.Item1.EntityType.FullName)
.ToList();
Assert.Equal(1, commandTrees.Count());
var resultTrees = converter.Convert(commandTrees).ToList();
Assert.Equal(1, resultTrees.Count());
var firstCommandTree = (DbUpdateCommandTree)resultTrees.First();
Assert.Equal(2, firstCommandTree.Parameters.Count());
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:29,代码来源:DynamicToFunctionModificationCommandConverterTests.cs
示例2: Can_generate_dynamic_insert_command_trees
public void Can_generate_dynamic_insert_command_trees()
{
var model = TestContext.CreateDynamicUpdateModel();
var commandTreeGenerator
= new ModificationCommandTreeGenerator(model);
var commandTrees
= commandTreeGenerator
.GenerateInsert(GetType().Namespace + ".FunctionsModel.SpecialOrder")
.ToList();
Assert.Equal(2, commandTrees.Count());
var commandTree = commandTrees.First();
Assert.Equal(8, commandTree.SetClauses.Count);
Assert.Equal("Order", commandTree.Target.VariableType.EdmType.Name);
Assert.NotNull(commandTree.Returning);
commandTree = commandTrees.Last();
Assert.Equal(8, commandTree.SetClauses.Count);
Assert.NotNull(commandTree.Returning);
Assert.Equal("special_orders", commandTree.Target.VariableType.EdmType.Name);
commandTrees
= commandTreeGenerator
.GenerateInsert(GetType().Namespace + ".FunctionsModel.Customer")
.ToList();
Assert.Equal(1, commandTrees.Count());
commandTree = commandTrees.Single();
Assert.Equal(1, commandTree.SetClauses.Count);
Assert.Equal("Customer", commandTree.Target.VariableType.EdmType.Name);
Assert.NotNull(commandTree.Returning);
}
示例3: Can_generate_insert_tree_when_self_ref_direct
public void Can_generate_insert_tree_when_self_ref_direct()
{
DbModel model;
using (var context = new WorldContext_Identity())
{
model = context.InternalContext.CodeFirstModel.CachedModelBuilder.BuildDynamicUpdateModel(ProviderRegistry.Sql2008_ProviderInfo);
}
var commandTreeGenerator = new ModificationCommandTreeGenerator(model);
var commandTrees = commandTreeGenerator.GenerateInsert(GetType().Namespace + ".Thing").ToList();
Assert.Equal(1, commandTrees.Count());
}
示例4: Can_convert_insert_command_trees
public void Can_convert_insert_command_trees()
{
var model = TestContext.CreateDynamicUpdateModel();
var modificationFunctionMapping
= TestContext.GetModificationFunctionMapping("ExtraSpecialOrder");
var converter
= new DynamicToFunctionModificationCommandConverter(
modificationFunctionMapping.Item1, modificationFunctionMapping.Item2);
var modificationCommandTreeGenerator
= new ModificationCommandTreeGenerator(model);
var commandTrees
= modificationCommandTreeGenerator
.GenerateInsert(modificationFunctionMapping.Item1.EntityType.FullName);
Assert.Equal(3, commandTrees.Count());
var resultTrees = converter.Convert(commandTrees);
Assert.Equal(3, resultTrees.Count());
var firstCommandTree = resultTrees.First();
Assert.Equal(8, firstCommandTree.Parameters.Count());
Assert.Equal(8, firstCommandTree.SetClauses.Count());
Assert.Equal("teh_codez", firstCommandTree.Parameters.ElementAt(0).Key);
Assert.Equal("Signature", firstCommandTree.Parameters.ElementAt(1).Key);
Assert.Equal("the_name", firstCommandTree.Parameters.ElementAt(2).Key);
Assert.Equal("Address_Street", firstCommandTree.Parameters.ElementAt(3).Key);
Assert.Equal("Address_City", firstCommandTree.Parameters.ElementAt(4).Key);
Assert.Equal("Address_Country_Name", firstCommandTree.Parameters.ElementAt(5).Key);
Assert.Equal("OrderGroupId", firstCommandTree.Parameters.ElementAt(6).Key);
Assert.Equal("Customer_CustomerId", firstCommandTree.Parameters.ElementAt(7).Key);
var properties = ((RowType)firstCommandTree.Returning.ResultType.EdmType).Properties;
Assert.Equal(4, properties.Count);
Assert.Equal("key_result", properties[1].Name);
}
开发者ID:christiandpena,项目名称:entityframework,代码行数:43,代码来源:DynamicToFunctionModificationCommandConverterTests.cs
示例5: Can_generate_insert_tree_when_ia_required_to_many
public void Can_generate_insert_tree_when_ia_required_to_many()
{
DbModel model;
using (var context = new ArubaContext())
{
model
= context
.InternalContext
.CodeFirstModel
.CachedModelBuilder
.BuildDynamicUpdateModel(ProviderRegistry.Sql2008_ProviderInfo);
}
var commandTreeGenerator
= new ModificationCommandTreeGenerator(model);
var commandTrees
= commandTreeGenerator
.GenerateInsert(GetType().Namespace + ".ArubaTask")
.ToList();
Assert.Equal(1, commandTrees.Count());
}
示例6: Can_generate_insert_tree_when_table_splitting_dependent
public void Can_generate_insert_tree_when_table_splitting_dependent()
{
DbModel model;
using (var context = new TableSplittingContext())
{
model
= context
.InternalContext
.CodeFirstModel
.CachedModelBuilder
.BuildDynamicUpdateModel(ProviderRegistry.Sql2008_ProviderInfo);
}
var commandTreeGenerator
= new ModificationCommandTreeGenerator(model);
var commandTrees
= commandTreeGenerator
.GenerateInsert(GetType().Namespace + ".StandingStone")
.ToList();
Assert.Equal(1, commandTrees.Count());
Assert.IsType<DbUpdateCommandTree>(commandTrees.Single());
}
示例7: BuildCreateProcedureOperations
private IEnumerable<CreateProcedureOperation> BuildCreateProcedureOperations(
StorageEntityTypeModificationFunctionMapping modificationFunctionMapping,
ModificationCommandTreeGenerator modificationCommandTreeGenerator,
MigrationSqlGenerator migrationSqlGenerator)
{
DebugCheck.NotNull(modificationFunctionMapping);
var insertCommandTrees = new DbInsertCommandTree[0];
var updateCommandTrees = new DbUpdateCommandTree[0];
var deleteCommandTrees = new DbDeleteCommandTree[0];
if (modificationCommandTreeGenerator != null)
{
var dynamicToFunctionModificationCommandConverter
= new DynamicToFunctionModificationCommandConverter(
modificationFunctionMapping,
_target.StorageEntityContainerMapping);
insertCommandTrees
= dynamicToFunctionModificationCommandConverter
.Convert(
modificationCommandTreeGenerator
.GenerateInsert(modificationFunctionMapping.EntityType.Identity))
.ToArray();
updateCommandTrees
= dynamicToFunctionModificationCommandConverter
.Convert(
modificationCommandTreeGenerator
.GenerateUpdate(modificationFunctionMapping.EntityType.Identity))
.ToArray();
deleteCommandTrees
= dynamicToFunctionModificationCommandConverter
.Convert(
modificationCommandTreeGenerator
.GenerateDelete(modificationFunctionMapping.EntityType.Identity))
.ToArray();
}
string insertBodySql = null, updateBodySql = null, deleteBodySql = null;
if (migrationSqlGenerator != null)
{
var providerManifestToken
= _target.ProviderInfo.ProviderManifestToken;
insertBodySql
= migrationSqlGenerator
.GenerateProcedureBody(insertCommandTrees, null, providerManifestToken);
updateBodySql
= migrationSqlGenerator.GenerateProcedureBody(
updateCommandTrees,
modificationFunctionMapping.UpdateFunctionMapping.RowsAffectedParameterName,
providerManifestToken);
deleteBodySql
= migrationSqlGenerator.GenerateProcedureBody(
deleteCommandTrees,
modificationFunctionMapping.DeleteFunctionMapping.RowsAffectedParameterName,
providerManifestToken);
}
yield return BuildCreateProcedureOperation(
modificationFunctionMapping.InsertFunctionMapping.Function,
insertBodySql);
yield return BuildCreateProcedureOperation(
modificationFunctionMapping.UpdateFunctionMapping.Function,
updateBodySql);
yield return BuildCreateProcedureOperation(
modificationFunctionMapping.DeleteFunctionMapping.Function,
deleteBodySql);
}