本文整理汇总了C#中ModificationCommandTreeGenerator.GenerateAssociationInsert方法的典型用法代码示例。如果您正苦于以下问题:C# ModificationCommandTreeGenerator.GenerateAssociationInsert方法的具体用法?C# ModificationCommandTreeGenerator.GenerateAssociationInsert怎么用?C# ModificationCommandTreeGenerator.GenerateAssociationInsert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModificationCommandTreeGenerator
的用法示例。
在下文中一共展示了ModificationCommandTreeGenerator.GenerateAssociationInsert方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Can_generate_dynamic_insert_command_trees_for_many_to_many_association
public void Can_generate_dynamic_insert_command_trees_for_many_to_many_association()
{
var model = TestContext.CreateDynamicUpdateModel();
var commandTreeGenerator
= new ModificationCommandTreeGenerator(model);
var commandTrees
= commandTreeGenerator
.GenerateAssociationInsert(GetType().Namespace + ".FunctionsModel.OrderThing_Orders")
.ToList();
Assert.Equal(1, commandTrees.Count());
var commandTree = commandTrees.First();
Assert.Equal(5, commandTree.SetClauses.Count);
Assert.Equal("OrderThingOrder", commandTree.Target.VariableType.EdmType.Name);
Assert.Null(commandTree.Returning);
}
示例2: Can_convert_insert_command_trees_when_many_to_many
public void Can_convert_insert_command_trees_when_many_to_many()
{
var model = TestContext.CreateDynamicUpdateModel();
var modificationFunctionMapping
= TestContext.GetAssociationModificationFunctionMapping("OrderThing_Orders");
var converter
= new DynamicToFunctionModificationCommandConverter(
modificationFunctionMapping.Item1, modificationFunctionMapping.Item2);
var modificationCommandTreeGenerator
= new ModificationCommandTreeGenerator(model);
var commandTrees
= modificationCommandTreeGenerator
.GenerateAssociationInsert(modificationFunctionMapping.Item1.AssociationSet.ElementType.FullName);
Assert.Equal(1, commandTrees.Count());
var resultTrees = converter.Convert(commandTrees);
Assert.Equal(1, resultTrees.Count());
var commandTree = resultTrees.First();
Assert.Equal(5, commandTree.Parameters.Count());
Assert.Equal(5, commandTree.SetClauses.Count());
Assert.Equal("order_thing_id", commandTree.Parameters.ElementAt(0).Key);
Assert.Equal("Order_Id", commandTree.Parameters.ElementAt(1).Key);
Assert.Equal("Order_Key", commandTree.Parameters.ElementAt(2).Key);
Assert.Equal("teh_codez_bro", commandTree.Parameters.ElementAt(3).Key);
Assert.Equal("Order_Signature", commandTree.Parameters.ElementAt(4).Key);
Assert.Null(commandTree.Returning);
}
开发者ID:christiandpena,项目名称:entityframework,代码行数:36,代码来源:DynamicToFunctionModificationCommandConverterTests.cs
示例3: Can_generate_insert_association_tree_when_many_to_many_self_ref
public void Can_generate_insert_association_tree_when_many_to_many_self_ref()
{
DbModel model;
using (var context = new ManyToManySelfRef())
{
model
= context
.InternalContext
.CodeFirstModel
.CachedModelBuilder
.BuildDynamicUpdateModel(ProviderRegistry.Sql2008_ProviderInfo);
}
var commandTreeGenerator
= new ModificationCommandTreeGenerator(model);
var commandTrees
= commandTreeGenerator
.GenerateAssociationInsert(GetType().Namespace + ".ArubaPerson_Children")
.ToList();
Assert.Equal(1, commandTrees.Count());
}
示例4: Can_generate_insert_association_tree_when_many_to_many_with_abstract_target_end
public void Can_generate_insert_association_tree_when_many_to_many_with_abstract_target_end()
{
DbModel model;
using (var context = new GearsModelManyToMany())
{
model
= context
.InternalContext
.CodeFirstModel
.CachedModelBuilder
.BuildDynamicUpdateModel(ProviderRegistry.Sql2008_ProviderInfo);
}
var commandTreeGenerator
= new ModificationCommandTreeGenerator(model);
var commandTrees
= commandTreeGenerator
.GenerateAssociationInsert(GetType().Namespace + ".GearBase_Weapons")
.ToList();
Assert.Equal(1, commandTrees.Count());
}
示例5: BuildCreateProcedureOperations
private IEnumerable<CreateProcedureOperation> BuildCreateProcedureOperations(
StorageAssociationSetModificationFunctionMapping modificationFunctionMapping,
ModificationCommandTreeGenerator modificationCommandTreeGenerator,
MigrationSqlGenerator migrationSqlGenerator)
{
DebugCheck.NotNull(modificationFunctionMapping);
var insertCommandTrees = new DbInsertCommandTree[0];
var deleteCommandTrees = new DbDeleteCommandTree[0];
if (modificationCommandTreeGenerator != null)
{
var dynamicToFunctionModificationCommandConverter
= new DynamicToFunctionModificationCommandConverter(
modificationFunctionMapping,
_target.StorageEntityContainerMapping);
insertCommandTrees
= dynamicToFunctionModificationCommandConverter
.Convert(
modificationCommandTreeGenerator
.GenerateAssociationInsert(modificationFunctionMapping.AssociationSet.ElementType.Identity))
.ToArray();
deleteCommandTrees
= dynamicToFunctionModificationCommandConverter
.Convert(
modificationCommandTreeGenerator
.GenerateAssociationDelete(modificationFunctionMapping.AssociationSet.ElementType.Identity))
.ToArray();
}
string insertBodySql = null, deleteBodySql = null;
if (migrationSqlGenerator != null)
{
var providerManifestToken
= _target.ProviderInfo.ProviderManifestToken;
insertBodySql
= migrationSqlGenerator
.GenerateProcedureBody(insertCommandTrees, null, providerManifestToken);
deleteBodySql
= migrationSqlGenerator.GenerateProcedureBody(
deleteCommandTrees,
modificationFunctionMapping.DeleteFunctionMapping.RowsAffectedParameterName,
providerManifestToken);
}
yield return BuildCreateProcedureOperation(
modificationFunctionMapping.InsertFunctionMapping.Function,
insertBodySql);
yield return BuildCreateProcedureOperation(
modificationFunctionMapping.DeleteFunctionMapping.Function,
deleteBodySql);
}