/// <summary> /// Creates a table. /// </summary> public static DataTable CreateTable(IDbBindingCache bindingCache, object data) { if (data != null) { var type = data.GetType(); switch (TypeHelper.GetBindingMode(ref type, out _)) { case BindingMode.Class: { var bindingList = bindingCache.GetParametersBinding(type); var table = CreateTable(bindingList); AddRecord(table, bindingList, data); return(table); } case BindingMode.ClassList: { var bindingList = bindingCache.GetParametersBinding(type); var table = CreateTable(bindingList); var mi = typeof(SqlHelper).GetMethod(nameof(AddRecords), BindingFlags.Static | BindingFlags.NonPublic); mi.MakeGenericMethod(type).Invoke(null, new[] { table, bindingList, data }); return(table); } } } throw new NotImplementedException(); }
public override object FromDb(IDbBindingCache bindingCache, DbDataType dataType, Type type, object value) { switch (dataType) { case DbDataType.Unknown: case DbDataType.Boolean: case DbDataType.Char: case DbDataType.UInt8: case DbDataType.SInt8: case DbDataType.UInt16: case DbDataType.SInt16: case DbDataType.UInt24: case DbDataType.SInt24: case DbDataType.UInt32: case DbDataType.SInt32: case DbDataType.UInt64: case DbDataType.SInt64: case DbDataType.Decimal: case DbDataType.Float: case DbDataType.Double: case DbDataType.Time: case DbDataType.Date: case DbDataType.DateTime: case DbDataType.Timestamp: case DbDataType.TimeSpan: case DbDataType.Text: case DbDataType.Blob: case DbDataType.Enumerated: return(ScalarFromDb(type, value)); case DbDataType.Json: break; case DbDataType.Records: default: throw new NotImplementedException(); } return(value); }
public override object ToDb(IDbBindingCache bindingCache, DbDataType dataType, Type type, object value) { return(MySqlDataType.TranslateToDb(dataType, type, value)); }
/// <summary> /// Decodes a DB value into a C# value. /// </summary> public abstract object FromDb(IDbBindingCache bindingCache, DbDataType dataType, Type type, object value);