本文整理汇总了C#中IEntity.EntityKey方法的典型用法代码示例。如果您正苦于以下问题:C# IEntity.EntityKey方法的具体用法?C# IEntity.EntityKey怎么用?C# IEntity.EntityKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEntity
的用法示例。
在下文中一共展示了IEntity.EntityKey方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResolveConceptualAssociationValues
private void ResolveConceptualAssociationValues(IAssociation association, out IEntity principalEntity, out IEntity dependentEntity, out bool isParentEntity, out string keyName, out string toRole, out string fromRole)
{
bool isManyToManyEntity = association.IsParentManyToMany();
principalEntity = !isManyToManyEntity ? association.Entity : association.ForeignEntity;
dependentEntity = !isManyToManyEntity ? (association.AssociationType == AssociationType.ManyToMany) ? association.IntermediaryAssociation.Entity : association.ForeignEntity : association.IntermediaryAssociation.ForeignEntity;
toRole = ResolveEntityMappedName(principalEntity.EntityKey(), principalEntity.Name);
fromRole = ResolveEntityMappedName(dependentEntity.EntityKey(), dependentEntity.Name);
if (toRole.Equals(fromRole)) fromRole += 1;
keyName = ResolveAssociationMappedName(isManyToManyEntity ? association.Entity.EntityKeyName : association.AssociationKeyName);
isParentEntity = association.IsParentEntity;
if (association.AssociationType == AssociationType.ManyToMany)
isParentEntity &= association.IsParentManyToMany();
}
示例2: CreateMappingEntity
/// <summary>
/// 2.1: Update all of the Mapping Entities so we can guarantee and verify that our Mapping Associations End's exist.
///
/// <EntitySetMapping Name="Account">
/// <EntityTypeMapping TypeName="PetShopModel.Account">
/// <MappingFragment StoreEntitySet="Account">
/// <ScalarProperty Name="AccountId" ColumnName="AccountId" />
/// </MappingFragment>
/// </EntityTypeMapping>
/// </EntitySetMapping>
///
/// </summary>
/// <param name="entity">The Entity.</param>
private void CreateMappingEntity(IEntity entity)
{
if (_mappingEntitys.Contains(entity.Name))
{
Debug.WriteLine(String.Format("Already Processed Mapping Model Entity {0}", entity.Name), MappingCategory);
return;
}
//<EntitySetMapping Name="Categories">
#region Validate that an EntitySet Exists in the MappingStorageContainer.
var entitySet = MappingEntityContainer.EntitySetMappings.Where(e =>
entity.Name.Equals(e.Name, StringComparison.OrdinalIgnoreCase) || // Safe Name.
entity.EntityKeyName.Equals(e.Name, StringComparison.OrdinalIgnoreCase) || // Database Name.
(e.EntityTypeMappings.Count > 0 &&
e.EntityTypeMappings.Count(et => et.TypeName.Equals(String.Concat(ConceptualSchema.Namespace, ".", entity.Name), StringComparison.OrdinalIgnoreCase)) > 0 ||
e.EntityTypeMappings.Count(et => et.TypeName.Equals(String.Concat(ConceptualSchema.Namespace, ".", entity.EntityKeyName), StringComparison.OrdinalIgnoreCase)) > 0 ||
e.EntityTypeMappings.Count(et => et.TypeName.Equals(String.Format("IsTypeOf({0}.{1})", ConceptualSchema.Namespace, entity.Name), StringComparison.OrdinalIgnoreCase)) > 0 ||
e.EntityTypeMappings.Count(et => et.TypeName.Equals(String.Format("IsTypeOf({0}.{1})", ConceptualSchema.Namespace, entity.EntityKeyName), StringComparison.OrdinalIgnoreCase)) > 0 ||
e.EntityTypeMappings.Count(et => et.MappingFragments.Count > 0 && et.MappingFragments.Count(mf => mf.StoreEntitySet.Equals(entity.EntityKeyName, StringComparison.OrdinalIgnoreCase)) > 0) > 0)
).FirstOrDefault();
//NOTE: We could also possibly look up the table name by looking at the StorageModel's EntitySet Tables Property.
// If the Entity Set does not exist than create a new one.
if (entitySet == null)
{
entitySet = new EntitySetMapping() { Name = entity.Name };
MappingEntityContainer.EntitySetMappings.Add(entitySet);
}
#endregion
//<EntityTypeMapping TypeName="PetShopModel1.Category">
//<EntityTypeMapping TypeName="PetShopModel.CategoryChanged">
#region Validate the EntityType Mapping
string entityName = entity.Name;
var mapping = entitySet.EntityTypeMappings.FirstOrDefault();
if (mapping == null)
{
mapping = new EntityTypeMapping() { TypeName = String.Concat(ConceptualSchema.Namespace, ".", entity.Name) };
entitySet.EntityTypeMappings.Add(mapping);
}
else if (!String.IsNullOrEmpty(mapping.TypeName))
{
entityName = mapping.TypeName.Replace("IsTypeOf(", "").Replace(String.Format("{0}.", ConceptualSchema.Namespace), "").Replace(")", "");
entityName = entityName.Equals(entity.Name, StringComparison.OrdinalIgnoreCase)
? entity.Name
: entityName;
}
entitySet.Name = entityName;
// Check for inheritance.
mapping.TypeName = mapping.TypeName != null && mapping.TypeName.StartsWith("IsTypeOf") ?
String.Format("IsTypeOf({0}.{1})", ConceptualSchema.Namespace, entityName) :
String.Concat(ConceptualSchema.Namespace, ".", entityName);
_mappingEntityNames.Add(entity.EntityKey(), entityName);
// <MappingFragment StoreEntitySet="Category">
// <ScalarProperty Name="CategoryId" ColumnName="CategoryId" />
//</MappingFragment>
var mappingFragment = mapping.MappingFragments.Where(m => m.StoreEntitySet.Equals(entity.Name) || m.StoreEntitySet.Equals(entity.EntityKeyName)).FirstOrDefault();
if (mappingFragment == null)
{
mappingFragment = new MappingFragment() { StoreEntitySet = entity.Name };
mapping.MappingFragments.Add(mappingFragment);
}
mappingFragment.StoreEntitySet = entity.EntityKeyName;
//<ScalarProperty Name="LineNum" ColumnName="LineNum" />
MergeScalarProperties(mappingFragment, entity);
#endregion
_mappingEntitys.Add(entity.Name);
}
示例3: CreateConceptualEntitySet
private EntityContainer.EntitySetLocalType CreateConceptualEntitySet(IEntity entity, out string previousName, out bool isNewView)
{
previousName = String.Empty;
//<EntitySet Name="Categories" EntityType="PetShopModel1.Category" />
var entitySet = ConceptualSchemaEntityContainer.EntitySets.Where(e =>
e.EntityType.Equals(String.Concat(ConceptualSchema.Namespace, ".", ResolveEntityMappedName(entity.EntityKey(), entity.Name)), StringComparison.OrdinalIgnoreCase) ||
e.EntityType.Equals(String.Concat(ConceptualSchema.Namespace, ".", entity.EntityKeyName), StringComparison.OrdinalIgnoreCase) ||
entity.EntityKeyName.Equals(e.Name, StringComparison.OrdinalIgnoreCase) ||
ResolveEntityMappedName(entity.EntityKey(), entity.Name).Equals(e.Name, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
isNewView = entitySet == null && entity is ViewEntity;
if (entitySet == null)
{
entitySet = new EntityContainer.EntitySetLocalType { Name = ResolveEntityMappedName(entity.EntityKey(), entity.Name) };
ConceptualSchemaEntityContainer.EntitySets.Add(entitySet);
}
else
{
previousName = entitySet.Name;
}
// Set or sync the default values.
entitySet.Name = ResolveEntityMappedName(entity.EntityKey(), entity.Name);
entitySet.EntityType = String.Concat(ConceptualSchema.Namespace, ".", ResolveEntityMappedName(entity.EntityKey(), entity.Name));
return entitySet;
}
示例4: CreateConceptualEntityType
private EntityType CreateConceptualEntityType(IEntity entity, string entitySetName, string previousName, ref bool isNewView, out bool isNewEntityType)
{
//<EntityType Name="Category">
var entityType = ConceptualSchema.EntityTypes.Where(e =>
previousName.Equals(e.Name, StringComparison.OrdinalIgnoreCase) ||
ResolveEntityMappedName(entity.EntityKey(), entity.Name).Equals(e.Name, StringComparison.OrdinalIgnoreCase) ||
entitySetName.Equals(e.Name, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
isNewEntityType = false;
if (entityType == null)
{
entityType = new EntityType()
{
Name = ResolveEntityMappedName(entity.EntityKey(), entity.Name),
Key = new EntityKeyElement()
};
ConceptualSchema.EntityTypes.Add(entityType);
isNewView = entity is ViewEntity;
isNewEntityType = true;
}
entityType.Name = ResolveEntityMappedName(entity.EntityKey(), entity.Name);
entityType.SetAttributeValue(EdmxConstants.IsViewEntityCustomAttribute, entity is ViewEntity ? Boolean.TrueString : null);
return entityType;
}
示例5: CreateConceptualEntity
private void CreateConceptualEntity(IEntity entity)
{
if (entity.IsParentManyToMany())
{
_conceptualEntitiesToRemove.Add(ResolveEntityMappedName(entity.EntityKey(), entity.Name));
return;
}
// Check to see if this has already been processed.
if (_conceptualEntitys.Contains(entity.Name))
return;
bool isNewView;
string previousName;
var entitySet = CreateConceptualEntitySet(entity, out previousName, out isNewView);
bool isNewEntityType;
var entityType = CreateConceptualEntityType(entity, entitySet.Name, previousName, ref isNewView, out isNewEntityType);
RemoveDuplicateConceptualEntityTypeKeysAndProperties(entityType);
// Remove extra properties values.
var properties = from property in entityType.Properties
where !(from prop in entity.Properties select prop.KeyName).Contains(property.Name) &&
_removedStorageEntityProperties.Contains(String.Format(PROPERTY_KEY, entity.EntityKeyName, property.Name).ToLower()) // And it has been removed from the storage model.
select property;
// Remove all of the key properties that don't exist in the table entity.
foreach (var property in properties)
{
entityType.Properties.Remove(property);
}
CreateConceptualEntityTypeKeys(entity, isNewView, entityType);
CreateConceptualEntityTypeProperties(entity, entityType, isNewEntityType);
ValidateConceptualEntityComplexProperties(entity, entityType);
_conceptualEntitys.Add(entity.Name);
}
示例6: CreateConceptualComplexType
private void CreateConceptualComplexType(IEntity entity, string complexTypeName = "")
{
complexTypeName = !String.IsNullOrEmpty(complexTypeName)
? complexTypeName
: entity is CommandEntity
? ResolveEntityMappedName(entity.EntityKey() + "complex", entity.Name)
: ResolveEntityMappedName(entity.EntityKey(), entity.Name);
//<ComplexType Name="GetCategoryById_Result">
// <Property Type="String" Name="CategoryId" Nullable="false" MaxLength="10" />
// <Property Type="String" Name="Name" Nullable="true" MaxLength="80" />
// <Property Type="String" Name="Descn" Nullable="true" MaxLength="255" />
//</ComplexType>
// Check to see if this has already been processed.
if (_conceptualComplexTypes.Contains(entity.Name)) return;
var type = ConceptualSchema.ComplexTypes.Where(c => c.Name.Equals(complexTypeName)).FirstOrDefault();
if (type == null)
{
type = new ComplexType() { Name = complexTypeName };
ConceptualSchema.ComplexTypes.Add(type);
}
type.Name = complexTypeName;
type.SetAttributeValue(EdmxConstants.IsFunctionEntityCustomAttribute, entity is CommandEntity ? Boolean.TrueString : null);
RemoveDuplicateConceptualComplexTypeProperties(entity, type, null);
CreateConceptualComplexProperties(entity, type);
_conceptualComplexTypes.Add(entity.Name);
}
示例7: CreateConceptualAssociationSetEnd
private EntityContainer.AssociationSetLocalType.EndLocalType CreateConceptualAssociationSetEnd(IEntity entity, string role, EntityContainer.AssociationSetLocalType set, EntityContainer.AssociationSetLocalType.EndLocalType otherEnd = null)
{
var end = otherEnd == null ?
set.Ends.Where(e => e.Role.Equals(entity.EntityKeyName) || e.Role.Equals(role)).FirstOrDefault() :
set.Ends.Where(e => !e.Equals(otherEnd)).FirstOrDefault();
if (end == null)
{
end = new EntityContainer.AssociationSetLocalType.EndLocalType() { Role = role };
set.Ends.Add(end);
}
end.Role = role;
end.EntitySet = ResolveEntityMappedName(entity.EntityKey(), entity.Name);
return end;
}
示例8: CreateConceptualAssociationEnd
private AssociationEnd CreateConceptualAssociationEnd(IEntity entity, string role, LinqToEdmx.Model.Conceptual.Association assocication, bool isCascadeDelete)
{
// <End Role="Category" Type="PetShopModel1.Category" Multiplicity="1">
// <OnDelete Action="Cascade" />
// </End>
// <End Role="Product" Type="PetShopModel1.Product" Multiplicity="*" />
var end = new AssociationEnd()
{
Role = role,
Type = String.Concat(ConceptualSchema.Namespace, ".", ResolveEntityMappedName(entity.EntityKey(), entity.Name))
};
if (isCascadeDelete)
{
end.OnDelete.Add(new OnAction() { Action = EdmxConstants.OnDeleteActionCascade });
}
assocication.Ends.Add(end);
return end;
}
示例9: AddChildList
private void AddChildList(IEntity entity, bool readOnly, bool child)
{
if (Configuration.Instance.ExcludeRegexIsMatch(entity.EntityKey()))
return;
if (readOnly)
{
if (ReadOnlyListEntities.Count > 0 && ReadOnlyListEntities.Contains(entity))
return;
if (ReadOnlyChildListEntities.Count > 0 && ReadOnlyChildListEntities.Contains(entity))
return;
if (child)
ReadOnlyChildListEntities.Add(entity);
else
ReadOnlyListEntities.Add(entity);
}
else
{
if (DynamicRootListEntities.Count > 0 && DynamicRootListEntities.Contains(entity))
return;
if (EditableRootListEntities.Count > 0 && EditableRootListEntities.Contains(entity))
return;
if (EditableChildListEntities.Count > 0 && EditableChildListEntities.Contains(entity))
return;
if (child)
EditableChildListEntities.Add(entity);
else
EditableRootListEntities.Add(entity);
}
}