本文整理汇总了C#中EntitySet.AddComponentSpecification方法的典型用法代码示例。如果您正苦于以下问题:C# EntitySet.AddComponentSpecification方法的具体用法?C# EntitySet.AddComponentSpecification怎么用?C# EntitySet.AddComponentSpecification使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntitySet
的用法示例。
在下文中一共展示了EntitySet.AddComponentSpecification方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Setup
public void Setup()
{
// Setup Database
database = new Database("DB1");
var table = new Table("User");
table.AddColumn(new Column("Name"));
table.AddColumn(new Column("AddressStreet"));
table.AddColumn(new Column("AddressCity"));
table.AddColumn(new Column("AddressCountry"));
database.AddTable(table);
// Setup Entities
entitySet = new EntitySetImpl();
Entity userEntity = new EntityImpl("User");
userEntity.AddProperty(new PropertyImpl("Name"));
// Create the Address type
spec = new ComponentSpecificationImpl("Address");
spec.AddProperty(new ComponentPropertyImpl("Street"));
spec.AddProperty(new ComponentPropertyImpl("City"));
spec.AddProperty(new ComponentPropertyImpl("Country"));
// Create the Address component for the User entity.
component = spec.CreateImplementedComponentFor(userEntity, "HomeAddress");
entitySet.AddEntity(userEntity);
entitySet.AddComponentSpecification(spec);
// Setup the Mappings
mappingSet = new MappingSetImpl(database, entitySet);
componentMapping = new ComponentMappingImpl();
mappingSet.AddMapping(componentMapping);
componentMapping.AddPropertyAndColumn(component.Properties[0], table.Columns[1]);
componentMapping.AddPropertyAndColumn(component.Properties[1], table.Columns[2]);
componentMapping.AddPropertyAndColumn(component.Properties[2], table.Columns[3]);
// Add the mapping between the Name property and the Name column in the database table.
mappingSet.ChangeMappedColumnFor(userEntity.ConcreteProperties[0]).To(table.Columns[0]);
}