本文整理汇总了C#中System.Data.Entity.Core.Metadata.Edm.EntitySet类的典型用法代码示例。如果您正苦于以下问题:C# EntitySet类的具体用法?C# EntitySet怎么用?C# EntitySet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EntitySet类属于System.Data.Entity.Core.Metadata.Edm命名空间,在下文中一共展示了EntitySet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Cannot_create_with_null_argument
public void Cannot_create_with_null_argument()
{
var entityType = new EntityType("ET", "N", DataSpace.CSpace);
var entitySet = new EntitySet("ES", "S", "T", "Q", entityType);
var function = new EdmFunction("F", "N", DataSpace.SSpace, new EdmFunctionPayload());
var parameterBindings = Enumerable.Empty<ModificationFunctionParameterBinding>();
var rowsAffectedParameter = new FunctionParameter("rows_affected", new TypeUsage(), ParameterMode.Out);
var resultBindings = Enumerable.Empty<ModificationFunctionResultBinding>();
Assert.Equal(
"entitySet",
Assert.Throws<ArgumentNullException>(
() => new ModificationFunctionMapping(
null, entityType, function,
parameterBindings, rowsAffectedParameter, resultBindings)).ParamName);
Assert.Equal(
"function",
Assert.Throws<ArgumentNullException>(
() => new ModificationFunctionMapping(
entitySet, entityType, null,
parameterBindings, rowsAffectedParameter, resultBindings)).ParamName);
Assert.Equal(
"parameterBindings",
Assert.Throws<ArgumentNullException>(
() => new ModificationFunctionMapping(
entitySet, entityType, function,
null, rowsAffectedParameter, resultBindings)).ParamName);
}
示例2: Can_clear_modification_function_mappings
public void Can_clear_modification_function_mappings()
{
var entityType = new EntityType("E", "N", DataSpace.CSpace);
var entitySet = new EntitySet("S", "N", null, null, entityType);
var function = new EdmFunction("F", "N", DataSpace.SSpace, new EdmFunctionPayload());
var container = new EntityContainer("C", DataSpace.CSpace);
container.AddEntitySetBase(entitySet);
var entitySetMapping =
new StorageEntitySetMapping(
entitySet,
new StorageEntityContainerMapping(container));
var functionMapping =
new StorageModificationFunctionMapping(
entitySet,
entityType,
function,
Enumerable.Empty<StorageModificationFunctionParameterBinding>(),
null,
null);
var entityFunctionMappings =
new StorageEntityTypeModificationFunctionMapping(entityType, functionMapping, null, null);
entitySetMapping.AddModificationFunctionMapping(entityFunctionMappings);
Assert.Equal(1, entitySetMapping.ModificationFunctionMappings.Count());
entitySetMapping.ClearModificationFunctionMappings();
Assert.Equal(0, entitySetMapping.ModificationFunctionMappings.Count());
}
示例3: AddEntityTypeMappingFragment
public void AddEntityTypeMappingFragment(
EntitySet entitySet, EntityType entityType, MappingFragment fragment)
{
Debug.Assert(fragment.Table == Table);
_entityTypes.Add(entitySet, entityType);
var defaultDiscriminatorColumn = fragment.GetDefaultDiscriminator();
foreach (var cm in fragment.ColumnMappings)
{
var columnMapping = FindOrCreateColumnMapping(cm.ColumnProperty);
columnMapping.AddMapping(
entityType,
cm.PropertyPath,
fragment.ColumnConditions.Where(cc => cc.Column == cm.ColumnProperty),
defaultDiscriminatorColumn == cm.ColumnProperty);
}
// Add any column conditions that aren't mapped to properties
foreach (
var cc in
fragment.ColumnConditions.Where(cc => fragment.ColumnMappings.All(pm => pm.ColumnProperty != cc.Column)))
{
var columnMapping = FindOrCreateColumnMapping(cc.Column);
columnMapping.AddMapping(entityType, null, new[] { cc }, defaultDiscriminatorColumn == cc.Column);
}
}
示例4: Cannot_create_function_if_entity_sets_not_null_an_not_matching_number_of_return_parameters
public void Cannot_create_function_if_entity_sets_not_null_an_not_matching_number_of_return_parameters()
{
var entitySet = new EntitySet("set", null, null, null, new EntityType("entity", "ns", DataSpace.CSpace));
Assert.Equal(
Resources.Strings.NumberOfEntitySetsDoesNotMatchNumberOfReturnParameters,
Assert.Throws<ArgumentException>(
() => new EdmFunction(
"foo",
"bar",
DataSpace.CSpace,
new EdmFunctionPayload()
{
EntitySets = new[] { entitySet, entitySet },
ReturnParameters =
new[]
{
new FunctionParameter(
"param",
TypeUsage.CreateDefaultTypeUsage(
PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Int32)),
ParameterMode.ReturnValue)
,
}
})).Message);
}
示例5: AddEntityTypeMappingFragment
public void AddEntityTypeMappingFragment(
EntitySet entitySet, EntityType entityType, StorageMappingFragment fragment)
{
Debug.Assert(fragment.Table == Table);
_entityTypes.Add(entitySet, entityType);
var defaultDiscriminatorColumn = fragment.GetDefaultDiscriminator();
StorageConditionPropertyMapping defaultDiscriminatorCondition = null;
if (defaultDiscriminatorColumn != null)
{
defaultDiscriminatorCondition =
fragment.ColumnConditions.SingleOrDefault(cc => cc.ColumnProperty == defaultDiscriminatorColumn);
}
foreach (var pm in fragment.ColumnMappings)
{
var columnMapping = FindOrCreateColumnMapping(pm.ColumnProperty);
columnMapping.AddMapping(
entityType,
pm.PropertyPath,
fragment.ColumnConditions.Where(cc => cc.ColumnProperty == pm.ColumnProperty),
defaultDiscriminatorColumn == pm.ColumnProperty);
}
// Add any column conditions that aren't mapped to properties
foreach (
var cc in
fragment.ColumnConditions.Where(cc => !fragment.ColumnMappings.Any(pm => pm.ColumnProperty == cc.ColumnProperty)))
{
var columnMapping = FindOrCreateColumnMapping(cc.ColumnProperty);
columnMapping.AddMapping(entityType, null, new[] { cc }, defaultDiscriminatorColumn == cc.ColumnProperty);
}
}
示例6: CloneWithDefiningQuery
// internal for testing
internal static EntitySet CloneWithDefiningQuery(EntitySet sourceEntitySet, string definingQuery)
{
Debug.Assert(sourceEntitySet != null, "sourceEntitySet != null");
Debug.Assert(!string.IsNullOrWhiteSpace(definingQuery), "invalid definingQuery");
var metadataProperties =
sourceEntitySet.MetadataProperties.Where(p => p.PropertyKind != PropertyKind.System).ToList();
// these properties make it possible for the designer to track
// back these types to their source db objects
if (sourceEntitySet.Schema != null)
{
metadataProperties.Add(
StoreModelBuilder.CreateStoreModelBuilderMetadataProperty(
SchemaAttributeName,
sourceEntitySet.Schema));
}
if (sourceEntitySet.Table != null)
{
metadataProperties.Add(
StoreModelBuilder.CreateStoreModelBuilderMetadataProperty(
NameAttributeName,
sourceEntitySet.Table));
}
return
EntitySet.Create(
sourceEntitySet.Name,
null,
null,
definingQuery,
sourceEntitySet.ElementType,
metadataProperties);
}
示例7: Can_get_and_set_ends_via_wrapper_properties
public void Can_get_and_set_ends_via_wrapper_properties()
{
var associationType
= new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace)
{
SourceEnd = new AssociationEndMember("S", new EntityType("E", "N", DataSpace.CSpace)),
TargetEnd = new AssociationEndMember("T", new EntityType("E", "N", DataSpace.CSpace))
};
var associationSet = new AssociationSet("A", associationType);
Assert.Null(associationSet.SourceSet);
Assert.Null(associationSet.TargetSet);
var sourceEntitySet = new EntitySet();
associationSet.SourceSet = sourceEntitySet;
var targetEntitySet = new EntitySet();
associationSet.TargetSet = targetEntitySet;
Assert.Same(sourceEntitySet, associationSet.SourceSet);
Assert.Same(targetEntitySet, associationSet.TargetSet);
}
示例8: GetTableName
/// <summary>
/// Helper method to get the table name for the given s-space <see cref="EntitySet" />.
/// </summary>
/// <param name="modelTable">The s-space entity set for the table.</param>
/// <returns>The table name.</returns>
protected virtual string GetTableName(EntitySet modelTable)
{
return modelTable.MetadataProperties.Contains("Table")
&& modelTable.MetadataProperties["Table"].Value != null
? (string)modelTable.MetadataProperties["Table"].Value
: modelTable.Name;
}
示例9: WriteMappingFragment_should_write_store_entity_set_name
public void WriteMappingFragment_should_write_store_entity_set_name()
{
var fixture = new Fixture();
var entityType = new EntityType("E", "N", DataSpace.CSpace);
var entitySet = new EntitySet("ES", "S", null, null, entityType);
var entityContainer = new EntityContainer("EC", DataSpace.SSpace);
entityContainer.AddEntitySetBase(entitySet);
var storageEntitySetMapping
= new EntitySetMapping(
entitySet,
new EntityContainerMapping(entityContainer));
TypeMapping typeMapping = new EntityTypeMapping(storageEntitySetMapping);
var mappingFragment = new MappingFragment(entitySet, typeMapping, false);
fixture.Writer.WriteMappingFragmentElement(mappingFragment);
Assert.Equal(
@"<MappingFragment StoreEntitySet=""ES"" />",
fixture.ToString());
}
示例10: Can_retrieve_properties
public void Can_retrieve_properties()
{
var source = new EntityType("Source", "N", DataSpace.CSpace);
var target = new EntityType("Target", "N", DataSpace.CSpace);
var sourceEnd = new AssociationEndMember("SourceEnd", source);
var targetEnd = new AssociationEndMember("TargetEnd", target);
var associationType
= AssociationType.Create(
"AT",
"N",
true,
DataSpace.CSpace,
sourceEnd,
targetEnd,
null,
null);
var sourceSet = new EntitySet("SourceSet", "S", "T", "Q", source);
var targetSet = new EntitySet("TargetSet", "S", "T", "Q", target);
var associationSet
= AssociationSet.Create(
"AS",
associationType,
sourceSet,
targetSet,
null);
var members = new List<EdmMember> { null, targetEnd };
var memberPath = new ModificationFunctionMemberPath(members, associationSet);
Assert.Equal(members, memberPath.Members);
Assert.Equal(targetEnd.Name, memberPath.AssociationSetEnd.Name);
}
示例11: Configure_association_set_should_call_configure_function_configurations
public void Configure_association_set_should_call_configure_function_configurations()
{
var modificationFunctionsConfiguration = new ModificationFunctionsConfiguration();
var mockModificationFunctionConfiguration = new Mock<ModificationFunctionConfiguration>();
modificationFunctionsConfiguration.Insert(mockModificationFunctionConfiguration.Object);
modificationFunctionsConfiguration.Delete(mockModificationFunctionConfiguration.Object);
var entitySet = new EntitySet();
entitySet.ChangeEntityContainerWithoutCollectionFixup(new EntityContainer("C", DataSpace.CSpace));
var storageModificationFunctionMapping
= new StorageModificationFunctionMapping(
entitySet,
new EntityType("E", "N", DataSpace.CSpace),
new EdmFunction("F", "N", DataSpace.SSpace),
new StorageModificationFunctionParameterBinding[0],
null,
null);
modificationFunctionsConfiguration.Configure(
new StorageAssociationSetModificationFunctionMapping(
new AssociationSet("AS", new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace)),
storageModificationFunctionMapping,
storageModificationFunctionMapping));
mockModificationFunctionConfiguration
.Verify(m => m.Configure(storageModificationFunctionMapping), Times.Exactly(2));
}
示例12: PrimaryParameterBindings_should_omit_original_value_parameters_when_update
public void PrimaryParameterBindings_should_omit_original_value_parameters_when_update()
{
var entitySet = new EntitySet();
entitySet.ChangeEntityContainerWithoutCollectionFixup(new EntityContainer("C", DataSpace.CSpace));
var storageModificationFunctionMapping
= new StorageModificationFunctionMapping(
entitySet,
new EntityType("E", "N", DataSpace.CSpace),
new EdmFunction("F", "N", DataSpace.SSpace),
new[]
{
new StorageModificationFunctionParameterBinding(
new FunctionParameter(),
new StorageModificationFunctionMemberPath(
new EdmMember[]
{
new EdmProperty("M")
},
null),
false)
},
null,
null);
var storageEntityTypeModificationFunctionMapping
= new StorageEntityTypeModificationFunctionMapping(
new EntityType("E", "N", DataSpace.CSpace),
storageModificationFunctionMapping,
storageModificationFunctionMapping,
storageModificationFunctionMapping);
Assert.Equal(2, storageEntityTypeModificationFunctionMapping.PrimaryParameterBindings.Count());
}
开发者ID:christiandpena,项目名称:entityframework,代码行数:34,代码来源:StorageEntityTypeModificationFunctionMappingTests.cs
示例13: Can_not_create_composable_function_import_mapping_with_entity_set_and_null_structural_type_mappings
public void Can_not_create_composable_function_import_mapping_with_entity_set_and_null_structural_type_mappings()
{
var entityType = new EntityType("E", "N", DataSpace.CSpace);
var entitySet = new EntitySet("ES", null, null, null, entityType);
var functionImport =
new EdmFunction(
"f",
"entityModel",
DataSpace.CSpace,
new EdmFunctionPayload
{
IsComposable = true,
EntitySets = new[] { entitySet },
ReturnParameters =
new[]
{
new FunctionParameter(
"ReturnType",
TypeUsage.CreateDefaultTypeUsage(entityType),
ParameterMode.ReturnValue)
}
});
Assert.Equal(
Strings.ComposableFunctionImportsReturningEntitiesNotSupported,
Assert.Throws<NotSupportedException>(
() => new FunctionImportMappingComposable(
functionImport,
new EdmFunction(
"f", "store", DataSpace.CSpace, new EdmFunctionPayload { IsComposable = true }),
null)).Message);
}
示例14: Add
public void Add(EntitySet entitySet, EntityType entityType)
{
DebugCheck.NotNull(entitySet);
DebugCheck.NotNull(entityType);
var i = 0;
List<EntityType> entityTypes;
if (!_entityTypes.TryGetValue(entitySet, out entityTypes))
{
entityTypes = new List<EntityType>();
_entityTypes.Add(entitySet, entityTypes);
}
for (; i < entityTypes.Count; i++)
{
if (entityTypes[i] == entityType)
{
return;
}
else if (entityType.IsAncestorOf(entityTypes[i]))
{
break;
}
}
entityTypes.Insert(i, entityType);
}
示例15: Can_get_entity_set
public void Can_get_entity_set()
{
var entityContainerMapping = new StorageEntityContainerMapping(new EntityContainer("C", DataSpace.CSpace));
var entitySet = new EntitySet();
var entitySetMapping = new StorageEntitySetMapping(entitySet, entityContainerMapping);
Assert.Same(entitySet, entitySetMapping.EntitySet);
}