本文整理汇总了C#中MappingSchema类的典型用法代码示例。如果您正苦于以下问题:C# MappingSchema类的具体用法?C# MappingSchema怎么用?C# MappingSchema使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MappingSchema类属于命名空间,在下文中一共展示了MappingSchema类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitGenericConvertProvider
public bool InitGenericConvertProvider(Type[] types, MappingSchema mappingSchema)
{
var changed = false;
if (_genericConvertProviders != null)
{
lock (_genericConvertProviders)
{
foreach (var type in _genericConvertProviders)
{
var args = type.Key.GetGenericArgumentsEx();
if (args.Length == types.Length)
{
if (type.Value.Aggregate(false, (cur,ts) => cur || ts.SequenceEqual(types)))
continue;
var gtype = type.Key.MakeGenericType(types);
var provider = (IGenericInfoProvider)Activator.CreateInstance(gtype);
provider.SetInfo(new MappingSchema(this));
type.Value.Add(types);
changed = true;
}
}
}
}
return changed;
}
示例2: SqlCeDataProvider
protected SqlCeDataProvider(string name, MappingSchema mappingSchema)
: base(name, mappingSchema)
{
SqlProviderFlags.IsSubQueryColumnSupported = false;
SetCharField("NChar", (r,i) => r.GetString(i).TrimEnd());
}
示例3: GetDataReader
public override IDataReader GetDataReader(MappingSchema schema, IDataReader dataReader)
{
return
dataReader is NpgsqlDataReader
? new NpgsqlDataReaderEx(schema, (NpgsqlDataReader)dataReader)
: base.GetDataReader(schema, dataReader);
}
示例4: BaseSchema2
public void BaseSchema2()
{
var ms1 = new MappingSchema();
var ms2 = new MappingSchema(ms1);
Convert<DateTime,string>.Lambda = d => d.ToString(DateTimeFormatInfo.InvariantInfo);
ms1.SetConverter<DateTime,string>(d => d.ToString(new CultureInfo("en-US", false).DateTimeFormat));
ms2.SetConverter<DateTime,string>(d => d.ToString(new CultureInfo("ru-RU", false).DateTimeFormat));
{
var c0 = Convert<DateTime,string>.Lambda;
var c1 = ms1.GetConverter<DateTime,string>();
var c2 = ms2.GetConverter<DateTime,string>();
Assert.AreEqual("01/20/2012 16:30:40", c0(new DateTime(2012, 1, 20, 16, 30, 40, 50, DateTimeKind.Utc)));
Assert.AreEqual("1/20/2012 4:30:40 PM", c1(new DateTime(2012, 1, 20, 16, 30, 40, 50, DateTimeKind.Utc)));
Assert.AreEqual("20.01.2012 16:30:40", c2(new DateTime(2012, 1, 20, 16, 30, 40, 50, DateTimeKind.Utc)));
}
Convert<string,DateTime>.Expression = s => DateTime.Parse(s, DateTimeFormatInfo.InvariantInfo);
ms1.SetConvertExpression<string,DateTime>(s => DateTime.Parse(s, new CultureInfo("en-US", false).DateTimeFormat));
ms2.SetConvertExpression<string,DateTime>(s => DateTime.Parse(s, new CultureInfo("ru-RU", false).DateTimeFormat));
{
var c0 = Convert<string,DateTime>.Lambda;
var c1 = ms1.GetConverter<string,DateTime>();
var c2 = ms2.GetConverter<string,DateTime>();
Assert.AreEqual(new DateTime(2012, 1, 20, 16, 30, 40), c0("01/20/2012 16:30:40"));
Assert.AreEqual(new DateTime(2012, 1, 20, 16, 30, 40), c1("1/20/2012 4:30:40 PM"));
Assert.AreEqual(new DateTime(2012, 1, 20, 16, 30, 40), c2("20.01.2012 16:30:40"));
}
}
示例5: OracleDataProvider
protected OracleDataProvider(string name, MappingSchema mappingSchema)
: base(name, mappingSchema)
{
SqlProviderFlags.MaxInListValuesCount = 1000;
SetCharField("Char", (r,i) => r.GetString(i).TrimEnd());
SetCharField("NChar", (r,i) => r.GetString(i).TrimEnd());
}
示例6: ServiceModelDataReader
public ServiceModelDataReader(MappingSchema mappingSchema, LinqServiceResult result)
{
_mappingSchema = mappingSchema;
_result = result;
for (var i = 0; i < result.FieldNames.Length; i++)
_ordinal.Add(result.FieldNames[i], i);
}
示例7: FullMappingSchema
public FullMappingSchema(DbManager db, bool ignoreLazyLoad = false, MappingSchema parentMappingSchema = null,
FactoryType factoryType = FactoryType.LazyLoading)
{
_db = db;
_parentMappingSchema = parentMappingSchema;
_factoryType = factoryType;
_ignoreLazyLoad = ignoreLazyLoad;
}
示例8: ScalarDataReaderMapper
public ScalarDataReaderMapper(
MappingSchema mappingSchema,
IDataReader dataReader,
NameOrIndexParameter nameOrIndex)
: base(mappingSchema, dataReader)
{
_index = nameOrIndex.ByName? dataReader.GetOrdinal(nameOrIndex.Name): nameOrIndex.Index;
}
示例9: FirebirdDataProvider
protected FirebirdDataProvider(string name, MappingSchema mappingSchema)
: base(name, mappingSchema)
{
SetCharField("CHAR", (r,i) => r.GetString(i).TrimEnd());
SetProviderField<IDataReader,TimeSpan,DateTime>((r,i) => r.GetDateTime(i) - new DateTime(1970, 1, 1));
SetProviderField<IDataReader,DateTime,DateTime>((r,i) => GetDateTime(r, i));
}
示例10: DB2DataProvider
protected DB2DataProvider(string name, MappingSchema mappingSchema)
: base(name, mappingSchema)
{
SqlProviderFlags.AcceptsTakeAsParameter = false;
SqlProviderFlags.AcceptsTakeAsParameterIfSkip = true;
SetCharField("CHAR", (r,i) => r.GetString(i).TrimEnd());
}
示例11: SetTable
public override void SetTable(MappingSchema mappingSchema, SqlTable table, MemberInfo member, IEnumerable<Expression> arguments, IEnumerable<ISqlExpression> sqlArgs)
{
table.SqlTableType = SqlTableType.Expression;
table.Name = Expression ?? member.Name;
table.TableArguments = ConvertArgs(member, sqlArgs.ToArray());
if (Schema != null) table.Owner = Schema;
if (Database != null) table.Database = Database;
}
示例12: ObjToDicTest
//[Test]
public void ObjToDicTest()
{
var obj = new TestObj { Country = CountryCodeEnum1.DZ, Other = OtherEnum1.EnumValue2 };
var sh = new MappingSchema { Extensions = TypeExtension.GetExtensions("Map.xml") };
var pars = sh.MapObjectToDictionary(obj);
Assert.AreEqual("DZ", pars["country_code"]);
Assert.AreEqual(101, pars["other"]);
}
示例13: SQLiteDataProvider
protected SQLiteDataProvider(string name, MappingSchema mappingSchema)
: base(name, mappingSchema)
{
SqlProviderFlags.IsSkipSupported = false;
SqlProviderFlags.IsSkipSupportedIfTake = true;
SetCharField("char", (r,i) => r.GetString(i).TrimEnd());
SetCharField("nchar", (r,i) => r.GetString(i).TrimEnd());
}
示例14: PostgreSQLDataProvider
protected PostgreSQLDataProvider(string name, MappingSchema mappingSchema)
: base(name, mappingSchema)
{
SqlProviderFlags.IsInsertOrUpdateSupported = false;
SetCharField("bpchar", (r,i) => r.GetString(i).TrimEnd());
_sqlOptimizer = new PostgreSQLSqlOptimizer(SqlProviderFlags);
}
示例15: DefaultValue1
public void DefaultValue1()
{
var ms = new MappingSchema();
ms.SetDefaultValue(typeof(int), -1);
var c = ms.GetConverter<int?,int>();
Assert.AreEqual(-1, c(null));
}