本文整理汇总了C#中MappingEntity类的典型用法代码示例。如果您正苦于以下问题:C# MappingEntity类的具体用法?C# MappingEntity怎么用?C# MappingEntity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MappingEntity类属于命名空间,在下文中一共展示了MappingEntity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetColumnDbType
public override string GetColumnDbType(MappingEntity entity, MemberInfo member)
{
AttributeMappingMember mm = ((AttributeMappingEntity)entity).GetMappingMember(member.Name);
if (mm != null && mm.Column != null && !string.IsNullOrEmpty(mm.Column.DbType))
return mm.Column.DbType;
return null;
}
示例2: IsAssociationRelationship
public override bool IsAssociationRelationship(MappingEntity entity, MemberInfo member)
{
if (IsMapped(entity, member) && !IsColumn(entity, member))
{
Type otherType = TypeHelper.GetElementType(TypeHelper.GetMemberType(member));
return !this.IsScalar(otherType);
}
return false;
}
示例3: GetAssociationKeyMembers
public override IEnumerable<MemberInfo> GetAssociationKeyMembers(MappingEntity entity, MemberInfo member)
{
AttributeMappingEntity thisEntity = (AttributeMappingEntity)entity;
AttributeMappingMember mm = thisEntity.GetMappingMember(member.Name);
if (mm != null && mm.Association != null)
{
return this.GetReferencedMembers(thisEntity, mm.Association.KeyMembers, "Association.KeyMembers", thisEntity.EntityType);
}
return base.GetAssociationKeyMembers(entity, member);
}
示例4: IsPrimaryKey
public override bool IsPrimaryKey(MappingEntity entity, MemberInfo member)
{
// Customers has CustomerID, Orders has OrderID, etc
if (this.IsColumn(entity, member))
{
string name = NameWithoutTrailingDigits(member.Name);
return member.Name.EndsWith("ID")
&& member.DeclaringType.Name.StartsWith(member.Name.Substring(0, member.Name.Length - 2));
}
return false;
}
示例5: IsPrimaryKey
public override bool IsPrimaryKey(MappingEntity entity, MemberInfo member)
{
// Customers has CustomerID, Orders has OrderID, etc
//if (this.IsColumn(entity, member))
//{
// string name = NameWithoutTrailingDigits(member.Name);
// return member.Name.EndsWith("ID") && member.DeclaringType.Name.StartsWith(member.Name.Substring(0, member.Name.Length - 2));
//}
//return false;
//TODO: 2010-7.17 更改 获取主键的方式;
return base.IsPrimaryKey(entity, member);
}
示例6: IsNestedEntity
public override bool IsNestedEntity(MappingEntity entity, MemberInfo member)
{
AttributeMappingMember mm = ((AttributeMappingEntity)entity).GetMappingMember(member.Name);
return mm != null && mm.NestedEntity != null;
}
示例7: GenerateSql
/// <summary>
/// Generate a SQL SELECT distinct for the specific mapping using the Dataset query
/// </summary>
/// <param name="mapping">
/// The mapping to generate the SQL for
/// </param>
/// <param name="sqlWhere">
/// The SQL Query WHERE keyword and where clauses or empty
/// </param>
/// <returns>
/// String with the SQL Query
/// </returns>
private string GenerateSql(MappingEntity mapping, string sqlWhere)
{
var columnList = new StringBuilder();
foreach (DataSetColumnEntity col in mapping.Columns)
{
columnList.AppendFormat(" {0},", col.Name);
}
columnList.Length = columnList.Length - 1;
return string.Format(
CultureInfo.InvariantCulture,
"SELECT DISTINCT {2} \n FROM ({0}) virtualDataset {1} \n ORDER BY {2} ",
this._innerSqlQuery,
sqlWhere,
columnList);
}
示例8: GetAssociationKeys
private void GetAssociationKeys(
MappingEntity entity, MemberInfo member, out List<MemberInfo> keyMembers, out List<MemberInfo> relatedKeyMembers)
{
MappingEntity entity2 = GetRelatedEntity(entity, member);
// find all members in common (same name)
var map1 = this.GetMappedMembers(entity).Where(m => this.IsColumn(entity, m)).ToDictionary(m => m.Name);
var map2 = this.GetMappedMembers(entity2).Where(m => this.IsColumn(entity2, m)).ToDictionary(m => m.Name);
var commonNames = map1.Keys.Intersect(map2.Keys).OrderBy(k => k);
keyMembers = new List<MemberInfo>();
relatedKeyMembers = new List<MemberInfo>();
foreach (string name in commonNames)
{
keyMembers.Add(map1[name]);
relatedKeyMembers.Add(map2[name]);
}
}
示例9: IsRelationshipTarget
public override bool IsRelationshipTarget(MappingEntity entity, MemberInfo member)
{
if (IsAssociationRelationship(entity, member))
{
if (typeof(IEnumerable).IsAssignableFrom(TypeHelper.GetMemberType(member)))
{
return true;
}
// is target of relationship if the assoctions keys are the same as this entities primary key
var pks = new HashSet<string>(this.GetPrimaryKeyMembers(entity).Select(m => m.Name));
var keys = new HashSet<string>(this.GetAssociationKeyMembers(entity, member).Select(m => m.Name));
return keys.IsSubsetOf(pks) && pks.IsSubsetOf(keys);
}
return false;
}
示例10: GetAlias
/// <summary>
/// 获取列别名
/// </summary>
/// <param name="entity"></param>
/// <param name="member"></param>
/// <returns></returns>
public override string GetAlias(MappingEntity entity, MemberInfo member)
{
AttributeMappingMember mm = ((AttributeMappingEntity)entity).GetMappingMember(member.Name);
return (mm != null && mm.Column != null) ? mm.Column.Alias : null;
}
示例11: GetKeyMember
/// <summary>
/// Gets the key member.
/// </summary>
/// <param name="entity">The entity.</param>
/// <param name="member">The member.</param>
/// <returns></returns>
private bool GetKeyMember(MappingEntity entity, MemberInfo member)
{
var a = member.GetCustomAttribute<AssociationAttribute>(false);
return a.Any(p => p.RelatedEntityID == entity.TableId.IfEmptyReplace(entity.EntityType.Name));
}
示例12: GetAssociationRelatedKey
private void GetAssociationRelatedKey(MappingEntity entity, MemberInfo member, out List<MemberInfo> relatedKeyMembers)
{
//TODO: 2010 - 7- 17 获取 外键引用列
MappingEntity entity2 = GetRelatedEntity(entity, member);
//
var map1 = this.GetMappedMembers(entity).Where(m => this.IsColumn(entity, m) ).ToDictionary(m => m.Name);
var map2 = this.GetMappedMembers(entity2).Where(m => this.IsColumn(entity2, m) ).ToDictionary(m => m.Name);
var keyMembers = new List<MemberInfo>();
relatedKeyMembers = new List<MemberInfo>();
//TODO:这边可能暂时有问题 ...待发现.. ..2010-7-17
//var ats = map1.Values.Where(p => GetKeyMember(entity2, p)).ToList();
var ats2 = map2.Values.Where(p => GetKeyMember(entity, p)).ToList();
//if (ats.Count() > 0)
// keyMembers.AddRange(ats);//
if (ats2.Count() > 0)
relatedKeyMembers.AddRange(ats2);
// 获取标记了
//[Association(Member = "Users", KeyMembers = "RoleID", RelatedEntityID = "Users", RelatedKeyMembers = "RoleID")]
//的信息
if (relatedKeyMembers.Count == 0)//&& keyMembers.Count == 0
{
var commonNames = map1.Keys.Intersect(map2.Keys).OrderBy(k => k);
foreach (string name in commonNames)
{
//keyMembers.Add(map1[name]);//
relatedKeyMembers.Add(map2[name]);
}
}
}
示例13: GetColumnName
public override string GetColumnName(MappingEntity entity, MemberInfo member)
{
AttributeMappingMember mm = ((AttributeMappingEntity)entity).GetMappingMember(member.Name);
if (mm != null && mm.Column != null && !string.IsNullOrEmpty(mm.Column.Name))
{
return mm.Column.Name;
}
return base.GetColumnName(entity, member);
}
示例14: Initialize
/// <summary>
/// Initialize component mappings for coded components and time dimension used in mappings in the dataflow
/// </summary>
/// <param name="dataflowRef">
/// The dataflow Ref.
/// </param>
/// <remarks>
/// This method should be called only once
/// </remarks>
private void Initialize(Sdmx.Model.Registry.DataflowRefBean dataflowRef)
{
this._mappingSet = DataAccess.GetMappingSet(
this._connectionStringSettings,
dataflowRef.Id,
dataflowRef.Version,
dataflowRef.AgencyID,
this._allowedDataflows);
if (this._mappingSet == null)
{
return;
}
NormallizeDatabaseProvider(this._connectionStringSettings);
this._mastoreAccess = new StructureAccess(this._connectionStringSettings);
this._xsMeasureDimensionConstraints.Clear();
this._componentMapping = new Dictionary<string, ComponentInfo>(this._mappingSet.Mappings.Count);
this._innerSqlQuery = this._mappingSet.DataSet.Query;
this._measureComponent = null;
this._timeTranscoder = null;
this._timeMapping = null;
this._timeDimension = null;
bool measureDimensionMapped = false;
foreach (MappingEntity mapping in this._mappingSet.Mappings)
{
foreach (ComponentEntity component in mapping.Components)
{
if (component.ComponentType == SdmxComponentType.TimeDimension)
{
this._timeTranscoder = TimeDimensionMapping.Create(
mapping, this._mappingSet.DataSet.Connection.DBType);
this._timeMapping = mapping;
this._timeDimension = component.Concept.Id;
}
else if (component.CodeList != null)
{
if (component.MeasureDimension)
{
measureDimensionMapped = true;
}
var compInfo = new ComponentInfo();
compInfo.Mapping = mapping;
compInfo.ComponentMapping = ComponentMapping.CreateComponentMapping(component, mapping);
compInfo.CodelistRef.Id = component.CodeList.Id;
compInfo.CodelistRef.Version = component.CodeList.Version;
compInfo.CodelistRef.AgencyID = component.CodeList.Agency;
this._componentMapping.Add(component.Concept.Id, compInfo);
}
}
}
if (!measureDimensionMapped)
{
foreach (ComponentEntity component in this._mappingSet.Dataflow.Dsd.Dimensions)
{
if (component.MeasureDimension)
{
this._measureComponent = component.Concept.Id;
}
}
foreach (ComponentEntity xsMeasure in this._mappingSet.Dataflow.Dsd.CrossSectionalMeasures)
{
this._xsMeasureDimensionConstraints.Add(xsMeasure.Concept.Id, xsMeasure);
}
}
}
示例15: GetRelatedEntity
public override MappingEntity GetRelatedEntity(MappingEntity entity, MemberInfo member)
{
AttributeMappingEntity thisEntity = (AttributeMappingEntity)entity;
AttributeMappingMember mm = thisEntity.GetMappingMember(member.Name);
if (mm != null)
{
if (mm.Association != null)
{
Type elementType = TypeHelper.GetElementType(TypeHelper.GetMemberType(member));
Type entityType = (mm.Association.RelatedEntityType != null) ? mm.Association.RelatedEntityType : elementType;
return this.GetReferencedEntity(elementType, mm.Association.RelatedEntityID, entityType, "Association.RelatedEntityID");
}
else if (mm.NestedEntity != null)
{
return mm.NestedEntity;
}
}
return base.GetRelatedEntity(entity, member);
}