本文整理汇总了C#中ProviderType.GetClosestRuntimeType方法的典型用法代码示例。如果您正苦于以下问题:C# ProviderType.GetClosestRuntimeType方法的具体用法?C# ProviderType.GetClosestRuntimeType怎么用?C# ProviderType.GetClosestRuntimeType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProviderType
的用法示例。
在下文中一共展示了ProviderType.GetClosestRuntimeType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateColumnAccess
private void GenerateColumnAccess(Type cType, ProviderType pType, int ordinal, LocalBuilder locOrdinal)
{
Type rType = pType.GetClosestRuntimeType();
MethodInfo readerMethod = this.GetReaderMethod(this.compiler.DataReaderType, rType);
MethodInfo bufferMethod = this.GetReaderMethod(typeof(DbDataReader), rType);
Label labIsNull = gen.DefineLabel();
Label labExit = gen.DefineLabel();
Label labReadFromBuffer = gen.DefineLabel();
// if (buffer != null) goto ReadFromBuffer
this.GenerateAccessBufferReader();
gen.Emit(OpCodes.Ldnull);
gen.Emit(OpCodes.Ceq);
gen.Emit(OpCodes.Brfalse, labReadFromBuffer);
// read from DataReader
// this.reader.IsNull?
this.GenerateAccessDataReader();
if(locOrdinal != null)
gen.Emit(OpCodes.Ldloc, locOrdinal);
else
this.GenerateConstInt(ordinal);
gen.Emit(GetMethodCallOpCode(this.compiler.DataReaderIsDBNullMethod), this.compiler.DataReaderIsDBNullMethod);
gen.Emit(OpCodes.Brtrue, labIsNull);
// this.reader.GetXXX()
this.GenerateAccessDataReader();
if(locOrdinal != null)
gen.Emit(OpCodes.Ldloc, locOrdinal);
else
this.GenerateConstInt(ordinal);
gen.Emit(GetMethodCallOpCode(readerMethod), readerMethod);
this.GenerateConvertToType(rType, cType, readerMethod.ReturnType);
gen.Emit(OpCodes.Br_S, labExit);
// read from BUFFER
gen.MarkLabel(labReadFromBuffer);
// this.bufferReader.IsNull?
this.GenerateAccessBufferReader();
if(locOrdinal != null)
gen.Emit(OpCodes.Ldloc, locOrdinal);
else
this.GenerateConstInt(ordinal);
gen.Emit(GetMethodCallOpCode(this.compiler.BufferReaderIsDBNullMethod), this.compiler.BufferReaderIsDBNullMethod);
gen.Emit(OpCodes.Brtrue, labIsNull);
// this.bufferReader.GetXXX()
this.GenerateAccessBufferReader();
if(locOrdinal != null)
gen.Emit(OpCodes.Ldloc, locOrdinal);
else
this.GenerateConstInt(ordinal);
gen.Emit(GetMethodCallOpCode(bufferMethod), bufferMethod);
this.GenerateConvertToType(rType, cType, bufferMethod.ReturnType);
gen.Emit(OpCodes.Br_S, labExit);
// return NULL
gen.MarkLabel(labIsNull);
this.GenerateDefault(cType);
gen.MarkLabel(labExit);
}