public static SListResponse <T> ListResponse <T>(DataTable data, SListRequest request, bool include_underscores = false) where T : new() { SListResponse <T> lst = new SListResponse <T>(); if (data.Rows.Count == 0) { lst.data = new List <T>(); return(lst); } lst.items_total = data.Rows.Count; DataTable dttOut = null; lst.items_per_page = lst.items_total; lst.page_count = 1; lst.page_current = 1; dttOut = data; lst.item_count = dttOut.Rows.Count; lst.data = new List <T>(); foreach (DataRow dr in dttOut.Rows) { T item = new T(); GDataTypeConverter.ObjectFromDataRow(item, dr, include_underscores); lst.data.Add(item); item = default(T); } return(lst); }
public static SListResponse <T> ListResponse <T>(DataSet data, SListRequest request, bool include_underscores = false) where T : new() { SListResponse <T> lst = new SListResponse <T>(); if (data.Tables[1].Rows.Count == 0) { lst.data = new List <T>(); return(lst); } lst.item_count = data.Tables[1].Rows.Count; lst.items_per_page = request.items_per_page; lst.items_total = int.Parse(data.Tables[0].Rows[0][0].ToString()); lst.page_current = request.current_page; lst.page_count = (int)Math.Ceiling((double)lst.items_total / lst.items_per_page); lst.success = true; lst.data = new List <T>(); foreach (DataRow dr in data.Tables[1].Rows) { T item = new T(); GDataTypeConverter.ObjectFromDataRow(item, dr, include_underscores); lst.data.Add(item); item = default(T); } return(lst); }
public string ExecDataTableStr(IDbCommand command) { DataTable dtt = ExecDataTable(command); if ((dtt == null) || (dtt.Rows.Count < 1)) { return(string.Empty); } else { return(GDataTypeConverter.DbToStr(dtt.Rows[0][0])); } }
public long ExecDataTableLng(IDbCommand command) { DataTable dtt = ExecDataTable(command); if ((dtt == null) || (dtt.Rows.Count < 1)) { return(0); } else { return(GDataTypeConverter.DbToLong(dtt.Rows[0][0])); } }
public Guid ExecDataTableGid(IDbCommand command) { DataTable dtt = ExecDataTable(command); if ((dtt == null) || (dtt.Rows.Count < 1)) { return(Guid.Empty); } else { return(GDataTypeConverter.DbToGid(dtt.Rows[0][0])); } }
public DateTime ExecDataTableDt(IDbCommand command) { DataTable dtt = ExecDataTable(command); if ((dtt == null) || (dtt.Rows.Count < 1)) { return(DateTime.MinValue); } else { return(GDataTypeConverter.DbToDt(dtt.Rows[0][0])); } }
public decimal ExecDataTableDec(IDbCommand command) { DataTable dtt = ExecDataTable(command); if ((dtt == null) || (dtt.Rows.Count < 1)) { return(0); } else { return(GDataTypeConverter.DbToDec(dtt.Rows[0][0])); } }
public bool ExecDataTableBln(IDbCommand command) { DataTable dtt = ExecDataTable(command); if ((dtt == null) || (dtt.Rows.Count < 1)) { return(false); } else { return(GDataTypeConverter.DbToBln(dtt.Rows[0][0])); } }
public string ExecScalarStr(IDbCommand command) { string result = string.Empty; if (_auto_open_close) { Open(); } command.Connection = _connection; command.CommandTimeout = _command_timeout; result = GDataTypeConverter.DbToStr(command.ExecuteScalar()); if (_auto_open_close) { Close(); } return(result); }
public long ExecScalarLng(IDbCommand command) { long result = 0; if (_auto_open_close) { Open(); } command.Connection = _connection; command.CommandTimeout = _command_timeout; result = GDataTypeConverter.DbToLong(command.ExecuteScalar()); if (_auto_open_close) { Close(); } return(result); }
public Guid ExecScalarGid(IDbCommand command) { Guid result = Guid.Empty; if (_auto_open_close) { Open(); } command.Connection = _connection; command.CommandTimeout = _command_timeout; result = GDataTypeConverter.DbToGid(command.ExecuteScalar()); if (_auto_open_close) { Close(); } return(result); }
public decimal ExecScalarDec(IDbCommand command) { Decimal result = 0; if (_auto_open_close) { Open(); } command.Connection = _connection; command.CommandTimeout = _command_timeout; result = GDataTypeConverter.DbToDec(command.ExecuteScalar()); if (_auto_open_close) { Close(); } return(result); }
public bool ExecScalarBln(IDbCommand command) { bool result = false; if (_auto_open_close) { Open(); } command.Connection = _connection; command.CommandTimeout = _command_timeout; result = GDataTypeConverter.DbToBln(command.ExecuteScalar()); if (_auto_open_close) { Close(); } return(result); }