private void BindMethod(ILGenerator generator, PropertyInfo bindProperty, int ordinal) { IDbBind bind = Context.Ado.DbBind; bool isNullableType = false; MethodInfo method = null; Type bindPropertyType = UtilMethods.GetUnderType(bindProperty, ref isNullableType); string dbTypeName = UtilMethods.GetParenthesesValue(DataRecord.GetDataTypeName(ordinal)); string propertyName = bindProperty.Name; string validPropertyName = bind.GetPropertyTypeName(dbTypeName); validPropertyName = validPropertyName == "byte[]" ? "byteArray" : validPropertyName; CSharpDataType validPropertyType = (CSharpDataType)Enum.Parse(typeof(CSharpDataType), validPropertyName); #region Sqlite Logic if (this.Context.CurrentConnectionConfig.DbType == DbType.Sqlite) { if (bindPropertyType.IsEnum()) { method = isNullableType ? getConvertEnum_Null.MakeGenericMethod(bindPropertyType) : getEnum.MakeGenericMethod(bindPropertyType); } else if (bindPropertyType == UtilConstants.IntType) { method = isNullableType ? getConvertInt32 : getInt32; } else if (bindPropertyType == UtilConstants.StringType) { method = getString; } else if (bindPropertyType == UtilConstants.ByteArrayType) { method = getValueMethod; generator.Emit(OpCodes.Call, method); generator.Emit(OpCodes.Unbox_Any, bindProperty.PropertyType); return; } else { method = isNullableType ? getSqliteTypeNull.MakeGenericMethod(bindPropertyType) : getSqliteType.MakeGenericMethod(bindPropertyType); } generator.Emit(OpCodes.Call, method); return; } ; #endregion #region Common Database Logic string bindProperyTypeName = bindPropertyType.Name.ToLower(); bool isEnum = bindPropertyType.IsEnum(); if (isEnum) { validPropertyType = CSharpDataType.@enum; } switch (validPropertyType) { case CSharpDataType.@int: CheckType(bind.IntThrow, bindProperyTypeName, validPropertyName, propertyName); if (bindProperyTypeName.IsContainsIn("int", "int32")) { method = isNullableType ? getConvertInt32 : getInt32; } if (bindProperyTypeName.IsContainsIn("int64")) { method = isNullableType ? getConvertInt64 : getInt64; } if (bindProperyTypeName.IsContainsIn("byte")) { method = isNullableType ? getConvertByte : getByte; } if (bindProperyTypeName.IsContainsIn("int16")) { method = isNullableType ? getConvertInt16 : getInt16; } break; case CSharpDataType.@bool: if (bindProperyTypeName == "bool" || bindProperyTypeName == "boolean") { method = isNullableType ? getConvertBoolean : getBoolean; } break; case CSharpDataType.@string: CheckType(bind.StringThrow, bindProperyTypeName, validPropertyName, propertyName); method = getString; if (bindProperyTypeName == "guid") { method = isNullableType ? getConvertStringGuid : getStringGuid; } break; case CSharpDataType.DateTime: CheckType(bind.DateThrow, bindProperyTypeName, validPropertyName, propertyName); if (bindProperyTypeName == "datetime") { method = isNullableType ? getConvertDateTime : getDateTime; } break; case CSharpDataType.@decimal: CheckType(bind.DecimalThrow, bindProperyTypeName, validPropertyName, propertyName); if (bindProperyTypeName == "decimal") { method = isNullableType ? getConvertDecimal : getDecimal; } break; case CSharpDataType.@float: case CSharpDataType.@double: CheckType(bind.DoubleThrow, bindProperyTypeName, validPropertyName, propertyName); if (bindProperyTypeName.IsIn("double", "single") && dbTypeName != "real") { method = isNullableType ? getConvertDouble : getDouble; } else { method = isNullableType ? getConvertFloat : getFloat; } break; case CSharpDataType.Guid: CheckType(bind.GuidThrow, bindProperyTypeName, validPropertyName, propertyName); if (bindProperyTypeName == "guid") { method = isNullableType ? getConvertGuid : getGuid; } break; case CSharpDataType.@byte: if (bindProperyTypeName == "byte") { method = isNullableType ? getConvertByte : getByte; } break; case CSharpDataType.@enum: method = isNullableType ? getConvertEnum_Null.MakeGenericMethod(bindPropertyType) : getEnum.MakeGenericMethod(bindPropertyType); break; case CSharpDataType.@short: CheckType(bind.ShortThrow, bindProperyTypeName, validPropertyName, propertyName); if (bindProperyTypeName == "int16" || bindProperyTypeName == "short") { method = isNullableType ? getConvertInt16 : getInt16; } break; case CSharpDataType.@long: if (bindProperyTypeName == "int64" || bindProperyTypeName == "long") { method = isNullableType ? getConvertInt64 : getInt64; } break; case CSharpDataType.DateTimeOffset: method = isNullableType ? getConvertdatetimeoffset : getdatetimeoffset; if (bindProperyTypeName == "datetime") { method = isNullableType ? getConvertdatetimeoffsetDate : getdatetimeoffsetDate; } break; default: method = getValueMethod; break; } if (method == null && bindPropertyType == UtilConstants.StringType) { method = getConvertString; } if (bindPropertyType == UtilConstants.ObjType) { method = getValueMethod; } if (method == null) { method = isNullableType ? getOtherNull.MakeGenericMethod(bindPropertyType) : getOther.MakeGenericMethod(bindPropertyType); } generator.Emit(OpCodes.Call, method); if (method == getValueMethod) { generator.Emit(OpCodes.Unbox_Any, bindProperty.PropertyType); } #endregion }