当前位置: 首页>>代码示例>>C#>>正文


C# Mapping.Table类代码示例

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


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

示例1: TablesUniquelyNamedOnlyWithinThread

		public void TablesUniquelyNamedOnlyWithinThread()
		{
			var uniqueIntegerList = new System.Collections.Concurrent.ConcurrentBag<int>();
			var method = new ThreadStart(() =>
			                             {
				                             Table tbl1 = new Table();
				                             Table tbl2 = new Table();

				                             // Store these values for later comparison
				                             uniqueIntegerList.Add(tbl1.UniqueInteger);
				                             uniqueIntegerList.Add(tbl2.UniqueInteger);

				                             // Ensure that within a thread we have unique integers
				                             Assert.AreEqual(tbl1.UniqueInteger + 1, tbl2.UniqueInteger);
			                             });

			var thread1 = new CrossThreadTestRunner(method);
			var thread2 = new CrossThreadTestRunner(method);

			thread1.Start();
			thread2.Start();

			thread1.Join();
			thread2.Join();

			// There should in total be 4 tables, but only two distinct identifiers.
			Assert.AreEqual(4, uniqueIntegerList.Count);
			Assert.AreEqual(2, uniqueIntegerList.Distinct().Count());
		}
开发者ID:nhibernate,项目名称:nhibernate-core,代码行数:29,代码来源:TableFixture.cs

示例2: AuditTable

   public AuditTable(Table dataTable, 
 INamingStrategy namingStrategy,
 IAuditColumnSource auditColumnSource)
   {
       _auditTable = BuildAuditTable(dataTable,
       namingStrategy, auditColumnSource);
   }
开发者ID:akhuang,项目名称:NHibernate,代码行数:7,代码来源:AuditTable.cs

示例3: TablesUniquelyNamed

		public void TablesUniquelyNamed()
		{
			Table tbl1 = new Table();
			Table tbl2 = new Table();

			Assert.AreEqual(tbl1.UniqueInteger + 1, tbl2.UniqueInteger);
		}
开发者ID:nhibernate,项目名称:nhibernate-core,代码行数:7,代码来源:TableFixture.cs

示例4: AuditTable

 public AuditTable(Table dataTable,
     INamingStrategy namingStrategy,
     IAuditColumnSource auditColumnSource)
 {
     this.auditColumnSource = auditColumnSource;
       auditTable = BuildAuditTable(dataTable, namingStrategy);
 }
开发者ID:michelelepri,项目名称:uNhAddIns,代码行数:7,代码来源:AuditTable.cs

示例5: IndexInfo

		internal IndexInfo(Table table, Index index)
		{
			_name = MakeName("IX_", table.Name, index.ColumnIterator);
			_columns = CollectionUtils.Map<Column, string>(
				index.ColumnIterator,
				delegate(Column column) { return column.Name; });
		}
开发者ID:nhannd,项目名称:Xian,代码行数:7,代码来源:IndexInfo.cs

示例6: GetAuditColumns

        public IEnumerable<AuditColumn> GetAuditColumns(Table dataTable)
        {
            var userStamp = new AuditColumn()
              {
            Name = "AuditUser",
            SqlType = "sysname",
            Length = 50,
            IsNullable = false,
            IncludeInPrimaryKey = true,
            ValueFunction = delegate(TriggerActions action)
            {
              return "system_user";
            }
              };

              var timeStamp = new AuditColumn()
              {
            Name = "AuditTimestamp",
            Value = new SimpleValue()
            {
              TypeName = NHibernateUtil.DateTime.Name
            },
            IsNullable = false,
            IncludeInPrimaryKey = true,
            ValueFunction = delegate(TriggerActions action)
            {
              return "getdate()";
            }
              };

              var operation = new AuditColumn()
              {
            Name = "AuditOperation",
            Value = new SimpleValue()
            {
              TypeName = NHibernateUtil.AnsiChar.Name
            },
            Length = 1,
            IsNullable = false,
            IncludeInPrimaryKey = false,
            ValueFunction = delegate(TriggerActions action)
            {
              switch (action)
              {
            case TriggerActions.INSERT:
              return "'I'";
            case TriggerActions.UPDATE:
              return "'U'";
            case TriggerActions.DELETE:
              return "'D'";
            default:
              throw new ArgumentOutOfRangeException("action");
              }
            }
              };

              return new AuditColumn[] {
            userStamp, timeStamp, operation
              };
        }
开发者ID:akhuang,项目名称:NHibernate,代码行数:60,代码来源:AuditColumnSource.cs

示例7: BindTimestamp

		private void BindTimestamp(HbmTimestamp timestampSchema, PersistentClass rootClass, Table table)
		{
			if (timestampSchema == null)
				return;

			string propertyName = timestampSchema.name;
			SimpleValue simpleValue = new SimpleValue(table);

			BindColumns(timestampSchema, simpleValue, propertyName);

			if (!simpleValue.IsTypeSpecified)
				simpleValue.TypeName = NHibernateUtil.Timestamp.Name;

			Mapping.Property property = new Mapping.Property(simpleValue);
			BindProperty(timestampSchema, property);

			// for version properties marked as being generated, make sure they are "always"
			// generated; "insert" is invalid. This is dis-allowed by the schema, but just to make
			// sure...

			if (property.Generation == PropertyGeneration.Insert)
				throw new MappingException("'generated' attribute cannot be 'insert' for versioning property");

			simpleValue.NullValue = timestampSchema.unsavedvalue;
			rootClass.Version = property;
			rootClass.AddProperty(property);
		}
开发者ID:pallmall,项目名称:WCell,代码行数:27,代码来源:RootClassBinder.cs

示例8: QuotedTableNameWithoutSchemaWithSqlLite

        public void QuotedTableNameWithoutSchemaWithSqlLite()
        {
            Table tbl = new Table();
            tbl.Name = "`name`";

            Assert.AreEqual("\"name\"", tbl.GetQualifiedName(dialect));
        }
开发者ID:paulbatum,项目名称:nhibernate,代码行数:7,代码来源:SQLiteDialectFixture.cs

示例9: QuotedTableNameWithSqlLite

        public void QuotedTableNameWithSqlLite()
        {
            Table tbl = new Table();
            tbl.Name = "`Group`";

            Assert.AreEqual("\"Group\"", tbl.GetQualifiedName(dialect));
        }
开发者ID:paulbatum,项目名称:nhibernate,代码行数:7,代码来源:SQLiteDialectFixture.cs

示例10: BuildSqlDropIndexString

		public static string BuildSqlDropIndexString(Dialect.Dialect dialect, Table table, string name, string defaultCatalog, string defaultSchema)
		{
			string ifExists = dialect.GetIfExistsDropConstraint(table, name);
			string drop = string.Format("drop index {0}", StringHelper.Qualify(table.GetQualifiedName(dialect, defaultCatalog, defaultSchema), name));
			string end = dialect.GetIfExistsDropConstraintEnd(table, name);
			return ifExists + Environment.NewLine + drop + Environment.NewLine + end;
		}
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:7,代码来源:Index.cs

示例11: BindId

		public void BindId(HbmId idSchema, PersistentClass rootClass, Table table)
		{
			if (idSchema != null)
			{
				var id = new SimpleValue(table);
				new TypeBinder(id, Mappings).Bind(idSchema.Type);

				rootClass.Identifier = id;

				Func<HbmColumn> defaultColumn = () => new HbmColumn
				{
					name = idSchema.name ?? RootClass.DefaultIdentifierColumnName,
					length = idSchema.length
				};

				new ColumnsBinder(id, Mappings).Bind(idSchema.Columns, false, defaultColumn);

				CreateIdentifierProperty(idSchema, rootClass, id);
				VerifiyIdTypeIsValid(id.Type, rootClass.EntityName);

				new IdGeneratorBinder(Mappings).BindGenerator(id, GetIdGenerator(idSchema));

				id.Table.SetIdentifierValue(id);

				BindUnsavedValue(idSchema, id);
			}
		}
开发者ID:jlevitt,项目名称:nhibernate-core,代码行数:27,代码来源:ClassIdBinder.cs

示例12: UnmatchingColumns

		public void UnmatchingColumns()
		{

			Table primaryTable = new Table();
			primaryTable.Name = "pktable";
			primaryTable.PrimaryKey = new PrimaryKey();
			Column pkColumn = new Column( NHibernateUtil.Int16, 0 );
			pkColumn.Name = "pk_column";

			primaryTable.PrimaryKey.AddColumn( pkColumn );

			Table fkTable = new Table();
			fkTable.Name = "fktable";

			ForeignKey fk = new ForeignKey();
			Column fkColumn1 = new Column( NHibernateUtil.Int16, 0 );
			fkColumn1.Name = "col1";

			Column fkColumn2 = new Column( NHibernateUtil.Int16, 0 );
			fkColumn2.Name = "col2";

			fk.AddColumn( fkColumn1 );
			fk.AddColumn( fkColumn2 );
			
			fk.Table = fkTable;

			fk.ReferencedTable = primaryTable;

		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:29,代码来源:ForeignKeyFixture.cs

示例13: UnmatchingColumns

		public void UnmatchingColumns()
		{
			Table primaryTable = new Table("pktable");
			primaryTable.PrimaryKey = new PrimaryKey();
			SimpleValue sv = new SimpleValue();
			sv.TypeName = NHibernateUtil.Int16.Name;
			Column pkColumn = new Column("pk_column");
			pkColumn.Value = sv;

			primaryTable.PrimaryKey.AddColumn(pkColumn);

			Table fkTable = new Table("fktable");

			ForeignKey fk = new ForeignKey();
			sv = new SimpleValue();
			sv.TypeName = NHibernateUtil.Int16.Name;
			Column fkColumn1 = new Column("col1");
			fkColumn1.Value = sv;

			sv = new SimpleValue();
			sv.TypeName = NHibernateUtil.Int16.Name;
			Column fkColumn2 = new Column("col2");
			fkColumn2.Value = sv;

			fk.AddColumn(fkColumn1);
			fk.AddColumn(fkColumn2);

			fk.Table = fkTable;

			fk.ReferencedTable = primaryTable;
			Assert.Throws<FKUnmatchingColumnsException>(() => fk.AlignColumns());
		}
开发者ID:NikGovorov,项目名称:nhibernate-core,代码行数:32,代码来源:ForeignKeyFixture.cs

示例14: BindIndex

		private static void BindIndex(string indexAttribute, Table table, Column column)
		{
			if (indexAttribute != null && table != null)
			{
				var tokens = indexAttribute.Split(',');
				System.Array.ForEach(tokens, t => table.GetOrCreateIndex(t.Trim()).AddColumn(column));
			}
		}
开发者ID:jlevitt,项目名称:nhibernate-core,代码行数:8,代码来源:ColumnsBinder.cs

示例15: CreateIdentifier

		private static SimpleValue CreateIdentifier(HbmId idSchema, PersistentClass rootClass, Table table)
		{
			SimpleValue iv = new SimpleValue(table);
			iv.TypeName = idSchema.type;
			rootClass.Identifier = iv;

			return iv;
		}
开发者ID:pallmall,项目名称:WCell,代码行数:8,代码来源:ClassIdBinder.cs


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