/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.ActorPic DataRowToModel(DataRow row) { Maticsoft.Model.ActorPic model=new Maticsoft.Model.ActorPic(); if (row != null) { if(row["id"]!=null && row["id"].ToString()!="") { model.id=int.Parse(row["id"].ToString()); } if(row["ActorName"]!=null) { model.ActorName=row["ActorName"].ToString(); } if(row["Introduce"]!=null) { model.Introduce=row["Introduce"].ToString(); } if(row["AddUser"]!=null) { model.AddUser=row["AddUser"].ToString(); } if(row["AddTime"]!=null && row["AddTime"].ToString()!="") { model.AddTime=DateTime.Parse(row["AddTime"].ToString()); } if(row["PicUrl"]!=null) { model.PicUrl=row["PicUrl"].ToString(); } if(row["Position"]!=null) { model.Position=row["Position"].ToString(); } if(row["PicID"]!=null && row["PicID"].ToString()!="") { model.PicID=int.Parse(row["PicID"].ToString()); } if(row["PicType"]!=null) { model.PicType=row["PicType"].ToString(); } if(row["OrderNum"]!=null && row["OrderNum"].ToString()!="") { model.OrderNum=int.Parse(row["OrderNum"].ToString()); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.ActorPic GetModel() { //该表无主键信息,请自定义主键/条件字段 StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 id,ActorName,Introduce,AddUser,AddTime,PicUrl,Position,PicID,PicType,OrderNum from ActorPic "); strSql.Append(" where "); SqlParameter[] parameters = { }; Maticsoft.Model.ActorPic model=new Maticsoft.Model.ActorPic(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }