/// <summary> /// 获得数据列表 /// </summary> public List<LogInFo> DataTableToList(DataTable dt) { List<LogInFo> modelList = new List<LogInFo>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { LogInFo model; for (int n = 0; n < rowsCount; n++) { model = new LogInFo(); if (dt.Rows[n]["ID"] != null && dt.Rows[n]["ID"].ToString() != "") { model.ID = int.Parse(dt.Rows[n]["ID"].ToString()); } if (dt.Rows[n]["LogLevel"] != null && dt.Rows[n]["LogLevel"].ToString() != "") { model.LogLevel = int.Parse(dt.Rows[n]["LogLevel"].ToString()); } if (dt.Rows[n]["LogDate"] != null && dt.Rows[n]["LogDate"].ToString() != "") { model.LogDate = DateTime.Parse(dt.Rows[n]["LogDate"].ToString()); } if (dt.Rows[n]["LogData"] != null && dt.Rows[n]["LogData"].ToString() != "") { model.LogData = dt.Rows[n]["LogData"].ToString(); } if (dt.Rows[n]["Source"] != null && dt.Rows[n]["Source"].ToString() != "") { model.Source = dt.Rows[n]["Source"].ToString(); } modelList.Add(model); } } return modelList; }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(LogInFo model) { return dal.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public void Add(LogInFo model) { dal.Add(model); }