• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Mapping.MetaType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Data.Linq.Mapping.MetaType的典型用法代码示例。如果您正苦于以下问题:C# MetaType类的具体用法?C# MetaType怎么用?C# MetaType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MetaType类属于System.Data.Linq.Mapping命名空间,在下文中一共展示了MetaType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GetKeys

		/// <summary>
		/// Returns a list of keys from the given meta type based on the key list string.
		/// </summary>
		/// <param name="keyListString">The key list string.</param>
		/// <param name="parentType">Type of the parent.</param>
		/// <returns></returns>
		private static ReadOnlyCollection<MetaDataMember> GetKeys(string keyListString, MetaType parentType)
		{
			if(keyListString != null)
			{
				var thisKeyList = new List<MetaDataMember>();

				string[] keyNames = keyListString.Split(STRING_SEPERATOR, StringSplitOptions.RemoveEmptyEntries);

				foreach (string rawKeyName in keyNames)
				{
					string keyName = rawKeyName.Trim();

					//TODO: maybe speed the lookup up
					MetaDataMember key = (from dataMember in parentType.PersistentDataMembers
					             where dataMember.Name == keyName
					             select dataMember).SingleOrDefault();

					if(key == null)
					{
						string errorMessage = string.Format("Could not find key member '{0}' of key '{1}' on type '{2}'. The key may be wrong or the field or property on '{2}' has changed names.",
							keyName, keyListString, parentType.Type.Name);

						throw new InvalidOperationException(errorMessage);
					}

					thisKeyList.Add(key);
				}

				return new ReadOnlyCollection<MetaDataMember>(thisKeyList);
			}
			else //Key is the primary key of this table
			{
				return parentType.IdentityMembers;
			}
		}
开发者ID:nlhepler,项目名称:mono,代码行数:41,代码来源:AttributedMetaAssociation.cs


示例2: AttributedColumnMetaDataMember

		public AttributedColumnMetaDataMember(MemberInfo member, ColumnAttribute attribute, MetaType declaringType)
            : base(member, declaringType, attribute)
        {
            columnAttribute = attribute;
            if (columnAttribute.Name == null)
                columnAttribute.Name = memberInfo.Name;
        }
开发者ID:nlhepler,项目名称:mono,代码行数:7,代码来源:AttributedColumnMetaDataMember.cs


示例3: SqlTable

		internal SqlTable(MetaTable table, MetaType rowType, ProviderType sqlRowType, Expression sourceExpression)
			: base(SqlNodeType.Table, sourceExpression) {
			this.table = table;
			this.rowType = rowType;
			this.sqlRowType = sqlRowType;
			this.columns = new List<SqlColumn>();
			}
开发者ID:modulexcite,项目名称:LinqToSQL2,代码行数:7,代码来源:SqlTable.cs


示例4: FindBase

		internal static MetaType FindBase(MetaType derivedType)
		{
			if(derivedType.Type == typeof(object))
			{
				return null;
			}

			var clrType = derivedType.Type; // start
			var rootClrType = derivedType.InheritanceRoot.Type; // end
			var metaTable = derivedType.Table;
			MetaType metaType = null;

			while(true)
			{
				if(clrType == typeof(object) || clrType == rootClrType)
				{
					return null;
				}

				clrType = clrType.BaseType;
				metaType = derivedType.InheritanceRoot.GetInheritanceType(clrType);

				if(metaType != null)
				{
					return metaType;
				}
			}
		}
开发者ID:modulexcite,项目名称:LinqToSQL2,代码行数:28,代码来源:InheritanceBaseFinder.cs


示例5: UnmappedDataMember

		internal UnmappedDataMember(MetaType declaringType, MemberInfo mi, int ordinal)
		{
			this.declaringType = declaringType;
			this.member = mi;
			this.ordinal = ordinal;
			this.type = TypeSystem.GetMemberType(mi);
		}
开发者ID:modulexcite,项目名称:LinqToSQL2,代码行数:7,代码来源:UnmappedDataMember.cs


示例6: DLinqTableProvider

        public DLinqTableProvider(DLinqDataModelProvider dataModel, MetaType rowType, string name, PropertyInfo prop)
            : base(dataModel) {
            _prop = prop;
            _rowType = rowType;
            Name = name;
            DataContextPropertyName = prop.Name;
            EntityType = rowType.Type;
            ParentEntityType = rowType.InheritanceBase != null ? rowType.InheritanceBase.Type : null;
            RootEntityType = rowType.Table.RowType.Type;

            _columns = new List<ColumnProvider>();
            var members = new List<MetaDataMember>(rowType.DataMembers);

            // Add in base-class-first order (not the typical derived-class-first order)
            foreach (PropertyInfo propInfo in GetOrderedProperties(rowType.Type)) {
                MetaDataMember member = members.FirstOrDefault(m => m.Member.Name == propInfo.Name);
                if (member != null) {
                    AddColumn(dataModel, member, propInfo);
                    members.Remove(member);
                }
            }

            // Anything we might've missed, tack it onto the end
            foreach (MetaDataMember member in members) {
                AddColumn(dataModel, member, (PropertyInfo)member.Member);
            }

            _roColumns = new ReadOnlyCollection<ColumnProvider>(_columns);
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:29,代码来源:DLinqTableProvider.cs


示例7: AttributedColumnMetaDataMember

 public AttributedColumnMetaDataMember(MemberInfo member, ColumnAttribute attribute, MetaType declaringType)
     : base(member, declaringType, member.DeclaringType.GetSingleMember(attribute.Storage))
 {
     columnAttribute = attribute;
     if (columnAttribute.Name == null)
         columnAttribute.Name = memberInfo.Name;
 }
开发者ID:TheRealDuckboy,项目名称:mono-soc-2008,代码行数:7,代码来源:AttributedColumnMetaDataMember.cs


示例8: RepositoryMetaType

 public RepositoryMetaType(string workspace, MetaType original, MetaTable table, MetaModel metaModel)
 {
     this.Workspace = workspace;
     this.Original = original;
     this.RepositoryMetaTable = table;
     this.RepositoryMetaModel = metaModel;
 }
开发者ID:perandersson,项目名称:contendio,代码行数:7,代码来源:RepositoryMetaType.cs


示例9: TypeFromDiscriminator

 /// <summary>
 /// Given a type root and a discriminator, return the type that would be instantiated.
 /// </summary>
 private static MetaType TypeFromDiscriminator(MetaType root, object discriminator) {
     foreach (MetaType type in root.InheritanceTypes) {
         if (IsSameDiscriminator(discriminator, type.InheritanceCode))
             return type;
     }
     return root.InheritanceDefault;
 }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:10,代码来源:ChangeTracker.cs


示例10: IsDeclaredBy

		public override bool IsDeclaredBy(MetaType metaType)
		{
			if(metaType == null)
			{
				throw Error.ArgumentNull("metaType");
			}
			return metaType.Type == this.member.DeclaringType;
		}
开发者ID:modulexcite,项目名称:LinqToSQL2,代码行数:8,代码来源:UnmappedDataMember.cs


示例11: AttributedMetaAssociation

		internal AttributedMetaAssociation(AttributedMetaDataMember member, AssociationAttribute attr)
		{
			this.thisMember = member;

			this.isMany = TypeSystem.IsSequenceType(this.thisMember.Type);
			Type ot = this.isMany ? TypeSystem.GetElementType(this.thisMember.Type) : this.thisMember.Type;
			this.otherType = this.thisMember.DeclaringType.Model.GetMetaType(ot);
			this.thisKey = (attr.ThisKey != null) ? MakeKeys(this.thisMember.DeclaringType, attr.ThisKey) : this.thisMember.DeclaringType.IdentityMembers;
			this.otherKey = (attr.OtherKey != null) ? MakeKeys(otherType, attr.OtherKey) : this.otherType.IdentityMembers;
			this.thisKeyIsPrimaryKey = AreEqual(this.thisKey, this.thisMember.DeclaringType.IdentityMembers);
			this.otherKeyIsPrimaryKey = AreEqual(this.otherKey, this.otherType.IdentityMembers);
			this.isForeignKey = attr.IsForeignKey;

			this.isUnique = attr.IsUnique;
			this.deleteRule = attr.DeleteRule;
			this.deleteOnNull = attr.DeleteOnNull;

			// if any key members are not nullable, the association is not nullable
			foreach(MetaDataMember mm in thisKey)
			{
				if(!mm.CanBeNull)
				{
					this.isNullable = false;
					break;
				}
			}

			// validate DeleteOnNull specification
			if(deleteOnNull == true)
			{
				if(!(isForeignKey && !isMany && !isNullable))
				{
					throw Error.InvalidDeleteOnNullSpecification(member);
				}
			}

			//validate the number of ThisKey columns is the same as the number of OtherKey columns
			if(this.thisKey.Count != this.otherKey.Count && this.thisKey.Count > 0 && this.otherKey.Count > 0)
			{
				throw Error.MismatchedThisKeyOtherKey(member.Name, member.DeclaringType.Name);
			}

			// determine reverse reference member
			foreach(MetaDataMember omm in this.otherType.PersistentDataMembers)
			{
				AssociationAttribute oattr = (AssociationAttribute)Attribute.GetCustomAttribute(omm.Member, typeof(AssociationAttribute));
				if(oattr != null)
				{
					if(omm != this.thisMember && oattr.Name == attr.Name)
					{
						this.otherMember = omm;
						break;
					}
				}
			}
		}
开发者ID:modulexcite,项目名称:LinqToSQL2,代码行数:56,代码来源:AttributedMetaAssociation.cs


示例12: MappedDataMember

		internal MappedDataMember(MetaType declaringType, MemberInfo mi, MemberMapping map, int ordinal)
		{
			this.declaringType = declaringType;
			this.member = mi;
			this.ordinal = ordinal;
			this.type = TypeSystem.GetMemberType(mi);
			this.isNullableType = TypeSystem.IsNullableType(this.type);
			this.memberMap = map;
			if(this.memberMap != null && this.memberMap.StorageMemberName != null)
			{
				MemberInfo[] mis = mi.DeclaringType.GetMember(this.memberMap.StorageMemberName, BindingFlags.Instance | BindingFlags.NonPublic);
				if(mis == null || mis.Length != 1)
				{
					throw Error.BadStorageProperty(this.memberMap.StorageMemberName, mi.DeclaringType, mi.Name);
				}
				this.storageMember = mis[0];
			}
			Type storageType = this.storageMember != null ? TypeSystem.GetMemberType(this.storageMember) : this.type;
			this.isDeferred = IsDeferredType(storageType);
			ColumnMapping cmap = map as ColumnMapping;
			if(cmap != null && cmap.IsDbGenerated && cmap.IsPrimaryKey)
			{
				// auto-gen identities must be synced on insert
				if((cmap.AutoSync != AutoSync.Default) && (cmap.AutoSync != AutoSync.OnInsert))
				{
					throw Error.IncorrectAutoSyncSpecification(mi.Name);
				}
			}
			if(cmap != null)
			{
				this.isPrimaryKey = cmap.IsPrimaryKey;
				this.isVersion = cmap.IsVersion;
				this.isDBGenerated = cmap.IsDbGenerated || !string.IsNullOrEmpty(cmap.Expression) || this.isVersion;
				this.isDiscriminator = cmap.IsDiscriminator;
				this.canBeNull = cmap.CanBeNull == null ? this.isNullableType || !this.type.IsValueType : (bool)cmap.CanBeNull;
				this.dbType = cmap.DbType;
				this.expression = cmap.Expression;
				this.updateCheck = cmap.UpdateCheck;
				// auto-gen keys are always and only synced on insert
				if(this.IsDbGenerated && this.IsPrimaryKey)
				{
					this.autoSync = AutoSync.OnInsert;
				}
				else if(cmap.AutoSync != AutoSync.Default)
				{
					// if the user has explicitly set it, use their value
					this.autoSync = cmap.AutoSync;
				}
				else if(this.IsDbGenerated)
				{
					// database generated members default to always
					this.autoSync = AutoSync.Always;
				}
			}
			this.mappedName = this.memberMap.DbName != null ? this.memberMap.DbName : this.member.Name;
		}
开发者ID:modulexcite,项目名称:LinqToSQL2,代码行数:56,代码来源:MappedDataMember.cs


示例13: SqlDiscriminatedType

		internal SqlDiscriminatedType(ProviderType sqlType, SqlExpression discriminator, MetaType targetType, Expression sourceExpression)
			: base(SqlNodeType.DiscriminatedType,
				typeof(Type),
				sourceExpression) {
			if (discriminator == null)
				throw Error.ArgumentNull("discriminator");
			this.discriminator = discriminator;
			this.targetType = targetType;
			this.sqlType = sqlType;
				}
开发者ID:modulexcite,项目名称:LinqToSQL2,代码行数:10,代码来源:SqlDiscriminatedType.cs


示例14: SqlTypeCase

		internal SqlTypeCase(Type clrType, ProviderType sqlType, MetaType rowType, SqlExpression discriminator, IEnumerable<SqlTypeCaseWhen> whens, Expression sourceExpression)
			: base(SqlNodeType.TypeCase, clrType, sourceExpression) {
			this.Discriminator = discriminator;
			if (whens == null)
				throw Error.ArgumentNull("whens");
			this.whens.AddRange(whens);
			if (this.whens.Count == 0)
				throw Error.ArgumentOutOfRange("whens");
			this.sqlType = sqlType;
			this.rowType = rowType;
			}
开发者ID:modulexcite,项目名称:LinqToSQL2,代码行数:11,代码来源:SqlTypeCase.cs


示例15: SqlLink

		internal SqlLink(object id, MetaType rowType, Type clrType, ProviderType sqlType, SqlExpression expression, MetaDataMember member, IEnumerable<SqlExpression> keyExpressions, SqlExpression expansion, Expression sourceExpression)
			: base(SqlNodeType.Link, clrType, sqlType, sourceExpression) {
			this.id = id;
			this.rowType = rowType;
			this.expansion = expansion;
			this.expression = expression;
			this.member = member;
			this.keyExpressions = new List<SqlExpression>();
			if (keyExpressions != null)
				this.keyExpressions.AddRange(keyExpressions);
			}
开发者ID:modulexcite,项目名称:LinqToSQL2,代码行数:11,代码来源:SqlLink.cs


示例16: object

		object locktarget = new object(); // Hold locks on private object rather than public MetaType.

		internal AttributedMetaType(MetaModel model, MetaTable table, Type type, MetaType inheritanceRoot)
		{
			this.model = model;
			this.table = table;
			this.type = type;
			this.inheritanceRoot = (inheritanceRoot != null) ? inheritanceRoot : this;
			// Not lazy-loading to simplify locking and enhance performance 
			// (because no lock will be required for the common read scenario).
			this.InitDataMembers();
			this.identities = this.dataMembers.Where(m => m.IsPrimaryKey).ToList().AsReadOnly();
			this.persistentMembers = this.dataMembers.Where(m => m.IsPersistent).ToList().AsReadOnly();
		}
开发者ID:modulexcite,项目名称:LinqToSQL2,代码行数:14,代码来源:AttributedMetaType.cs


示例17: object

		private object locktarget = new object(); // Hold locks on private object rather than public MetaType.
		#endregion

		internal MappedType(MetaModel model, MetaTable table, TypeMapping typeMapping, Type type, MetaType inheritanceRoot)
		{
			this.model = model;
			this.table = table;
			this.typeMapping = typeMapping;
			this.type = type;
			this.inheritanceRoot = inheritanceRoot != null ? inheritanceRoot : this;
			this.InitDataMembers();

			this.identities = this.dataMembers.Where(m => m.IsPrimaryKey).ToList().AsReadOnly();
			this.persistentDataMembers = this.dataMembers.Where(m => m.IsPersistent).ToList().AsReadOnly();
		}
开发者ID:modulexcite,项目名称:LinqToSQL2,代码行数:15,代码来源:MappedType.cs


示例18: BuildDefaultQuery

        internal SqlSelect BuildDefaultQuery(MetaType rowType, bool allowDeferred, SqlLink link, Expression source) {
            System.Diagnostics.Debug.Assert(rowType != null && rowType.Table != null);
            if (rowType.HasInheritance && rowType.InheritanceRoot != rowType) {
                // RowType is expected to be an inheritance root.
                throw Error.ArgumentWrongValue("rowType");
            }
            SqlTable table = sql.Table(rowType.Table, rowType, source);
            SqlAlias tableAlias = new SqlAlias(table);
            SqlAliasRef tableAliasRef = new SqlAliasRef(tableAlias);

            SqlExpression projection = this.BuildProjection(tableAliasRef, table.RowType, allowDeferred, link, source);
            return new SqlSelect(projection, tableAlias, source);
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:13,代码来源:Translator.cs


示例19: AttributedAbstractMetaDataMember

		protected AttributedAbstractMetaDataMember(MemberInfo member, MetaType declaringType, DataAttribute attribute)
		{
			memberInfo = member;
			memberAccessor = LambdaMetaAccessor.Create(member, declaringType.Type);
			this.declaringType = declaringType;
			
			if(attribute.Storage != null)
			{
				storageMember = member.DeclaringType.GetSingleMember(attribute.Storage);
				if (storageMember != null)
					storageAccessor = LambdaMetaAccessor.Create(storageMember, declaringType.Type);
			}
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:13,代码来源:AttributedAbstractMetaDataMember.cs


示例20: AttributedMetaTable

        public AttributedMetaTable(TableAttribute attribute, MetaType type, MetaModel model)
        {
            _tableAttribute = attribute;
            _metaType = type;
        	_containingModel = model;

			//If the attribute doesn't specify a table name the name of the table class is used
			if(!string.IsNullOrEmpty(attribute.Name))
			{
				_tableName = attribute.Name;
			}
			else
			{
				_tableName = type.Name;
			}
        }
开发者ID:pacholik,项目名称:driving_scools_server,代码行数:16,代码来源:AttributedMetaTable.cs



注:本文中的System.Data.Linq.Mapping.MetaType类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# NodeTypes.SqlExpression类代码示例发布时间:2022-05-26
下一篇:
C# Mapping.MappingSource类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap