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


C# MappingSchema.SetDataType方法代码示例

本文整理汇总了C#中MappingSchema.SetDataType方法的典型用法代码示例。如果您正苦于以下问题:C# MappingSchema.SetDataType方法的具体用法?C# MappingSchema.SetDataType怎么用?C# MappingSchema.SetDataType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MappingSchema的用法示例。


在下文中一共展示了MappingSchema.SetDataType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Test

        public void Test()
        {
            var schema = new MappingSchema();
            schema.SetDataType(typeof (decimal), new SqlDataType(DataType.Decimal, 19, 4));

            var table = new SqlTable<Foo>(schema);

            Assert.That(table.Fields.Single().Value.Precision, Is.EqualTo(19));
            Assert.That(table.Fields.Single().Value.Scale, Is.EqualTo(4));
        }
开发者ID:ili,项目名称:linq2db,代码行数:10,代码来源:CreateDecimalTableColumnTests.cs

示例2: Test

		public void Test(string context)
		{
			var firebirdQuote = FirebirdSqlBuilder.IdentifierQuoteMode;

			var schema = new MappingSchema();

			schema.SetDataType(typeof(MyInt), DataType.Int32);

			schema.SetConvertExpression<MyInt,   int>          (x => x.Value);
			schema.SetConvertExpression<int,     MyInt>        (x => new MyInt { Value = x });
			schema.SetConvertExpression<Int64,   MyInt>        (x => new MyInt { Value = (int)x }); //SQLite
			schema.SetConvertExpression<decimal, MyInt>        (x => new MyInt { Value = (int)x }); //Oracle
			schema.SetConvertExpression<MyInt,   DataParameter>(x => new DataParameter { DataType = DataType.Int32, Value = x.Value });

			schema.GetFluentMappingBuilder()
				  .Entity<Entity>()
				  .HasTableName("Issue464")
				  .HasColumn(x => x.Id)
				  .HasColumn(x => x.Value);

			using (var db = new  DataConnection(context).AddMappingSchema(schema))
			{
				try
				{
					FirebirdSqlBuilder.IdentifierQuoteMode = FirebirdIdentifierQuoteMode.Auto;

					var temptable = db.CreateTable<Entity>();

					var data = new[]
					{
						new Entity {Id = 1, Value = new MyInt {Value = 1}},
						new Entity {Id = 2, Value = new MyInt {Value = 2}},
						new Entity {Id = 3, Value = new MyInt {Value = 3}}
					};

					temptable.BulkCopy(data);

					AreEqual(data, temptable.ToList());
				}
				finally
				{
					db.DropTable<Entity>();

					FirebirdSqlBuilder.IdentifierQuoteMode = firebirdQuote;
				}

			}
		}
开发者ID:ronnyek,项目名称:linq2db,代码行数:48,代码来源:Issue464Tests.cs

示例3: GetMyIntSchema

		private static MappingSchema GetMyIntSchema()
		{
			var schema = new MappingSchema();

			schema.SetDataType  (typeof(MyInt), DataType.Int32);
			schema.SetScalarType(typeof(MyInt));
			schema.SetCanBeNull (typeof(MyInt), false);

			schema.SetConvertExpression<MyInt,   int>          (x => x.RealValue);
			schema.SetConvertExpression<int,     MyInt>        (x => new MyInt { RealValue = x });
			schema.SetConvertExpression<Int64,   MyInt>        (x => new MyInt { RealValue = (int)x }); //SQLite
			schema.SetConvertExpression<decimal, MyInt>        (x => new MyInt { RealValue = (int)x }); //Oracle
			schema.SetConvertExpression<MyInt,   DataParameter>(x => new DataParameter { DataType = DataType.Int32, Value = x.RealValue });

			return schema;
		}
开发者ID:ronnyek,项目名称:linq2db,代码行数:16,代码来源:Issue496Tests.cs


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