using System; using System.Data; using System.Collections.Generic; using System.Text; using Microsoft.Practices.EnterpriseLibrary.Data; namespace DSWeb.Areas.TruckMng.DAL.MsWlInsureLtd { public partial class MsWlInsureLtdDAL { #region Inquery DataList static public List GetDataList(string strCondition) { var strSql = new StringBuilder(); strSql.Append("SELECT "); strSql.Append("Code,Name"); strSql.Append(" from tMsWlInsureLtd "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" where " + strCondition); } return SetData(strSql); } static public Models.MsWlInsureLtd.MsWlInsureLtd GetData(string condition) { var list = GetDataList(condition); if (list.Count > 0) return list[0]; return new Models.MsWlInsureLtd.MsWlInsureLtd(); } private static List SetData(StringBuilder strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { Models.MsWlInsureLtd.MsWlInsureLtd data = new Models.MsWlInsureLtd.MsWlInsureLtd(); #region Set DB data to Object data.Code = Convert.ToString(reader["Code"]); data.Name = Convert.ToString(reader["Name"]); #endregion headList.Add(data); } reader.Close(); } return headList; } #endregion #region 参照部分 #endregion } }