public static SimpDataEntery DataTableToSimpDataEntery(DataTable covDt) { int i = 0, iCnt = covDt.Columns.Count, r = 0, rCnt = covDt.Rows.Count; var simpCols = new SimpDataColInf[iCnt]; for (; i < iCnt; i++) { simpCols[i].name = covDt.Columns[i].ColumnName; simpCols[i].type = (DotNetType)Enum.Parse(typeof(DotNetType), covDt.Columns[i].DataType.Name); } var simpRows = new List <object[]>(); for (; r < rCnt; r++) { var objs = covDt.Rows[r].ItemArray; ConvertObjects(ref objs); simpRows.Add(objs); } var simpDt = new SimpDataEntery { Cols = simpCols, Rows = simpRows, TVal = DateTime.Now.Ticks }; return(simpDt); }
private static DataTable SimpDataToDataTable(SimpDataEntery simpEnty, string tbname) { if (simpEnty == null) { return(null); } var dt = new DataTable(); for (int i = 0, iCnt = simpEnty.Cols.Length; i < iCnt; i++) { dt.Columns.Add(simpEnty.Cols[i].name, GetDotNetType(simpEnty.Cols[i].type)); } if (simpEnty.Key != null) { dt.PrimaryKey = new[] { dt.Columns[simpEnty.Key] } } ; for (int i = 0, iCnt = simpEnty.Rows.Count; i < iCnt; i++) { dt.LoadDataRow(simpEnty.Rows[i], false); } dt.TableName = tbname; return(dt); }
public static SimpDataEntery DataRowToSimpDataEntery(DataRow dr) { var dt = dr.Table; int i = 0, iCnt = dt.Columns.Count; var simpCols = new SimpDataColInf[iCnt]; for (; i < iCnt; i++) { simpCols[i].name = dt.Columns[i].ColumnName; simpCols[i].type = (DotNetType)Enum.Parse(typeof(DotNetType), dt.Columns[i].DataType.Name); } var objs = dr.ItemArray; ConvertObjects(ref objs); var simpRows = new List <object[]> { objs }; var simpDt = new SimpDataEntery { Cols = simpCols, Rows = simpRows, TVal = DateTime.Now.Ticks }; return(simpDt); }