/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.StorePicturesTable GetModel(string StorePicturesID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 StorePicturesID,BusPhotoAlbumID,BusinessID,UsersID,PictureAddress,PicName,IsUserUpload,PicState,UploadTime,NickName,IsSetTop,LikeCount,ShareCount from StorePicturesTable "); strSql.Append(" where StorePicturesID=@StorePicturesID "); SqlParameter[] parameters = { new SqlParameter("@StorePicturesID", SqlDbType.NVarChar,50) }; parameters[0].Value = StorePicturesID; Maticsoft.Model.StorePicturesTable model=new Maticsoft.Model.StorePicturesTable(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.StorePicturesTable DataRowToModel(DataRow row) { Maticsoft.Model.StorePicturesTable model=new Maticsoft.Model.StorePicturesTable(); if (row != null) { if(row["StorePicturesID"]!=null) { model.StorePicturesID=row["StorePicturesID"].ToString(); } if(row["BusPhotoAlbumID"]!=null) { model.BusPhotoAlbumID=row["BusPhotoAlbumID"].ToString(); } if(row["BusinessID"]!=null) { model.BusinessID=row["BusinessID"].ToString(); } if(row["UsersID"]!=null) { model.UsersID=row["UsersID"].ToString(); } if(row["PictureAddress"]!=null) { model.PictureAddress=row["PictureAddress"].ToString(); } if(row["PicName"]!=null) { model.PicName=row["PicName"].ToString(); } if(row["IsUserUpload"]!=null && row["IsUserUpload"].ToString()!="") { if((row["IsUserUpload"].ToString()=="1")||(row["IsUserUpload"].ToString().ToLower()=="true")) { model.IsUserUpload=true; } else { model.IsUserUpload=false; } } if(row["PicState"]!=null && row["PicState"].ToString()!="") { model.PicState=int.Parse(row["PicState"].ToString()); } if(row["UploadTime"]!=null && row["UploadTime"].ToString()!="") { model.UploadTime=DateTime.Parse(row["UploadTime"].ToString()); } if(row["NickName"]!=null) { model.NickName=row["NickName"].ToString(); } if(row["IsSetTop"]!=null && row["IsSetTop"].ToString()!="") { if((row["IsSetTop"].ToString()=="1")||(row["IsSetTop"].ToString().ToLower()=="true")) { model.IsSetTop=true; } else { model.IsSetTop=false; } } if(row["LikeCount"]!=null && row["LikeCount"].ToString()!="") { model.LikeCount=int.Parse(row["LikeCount"].ToString()); } if(row["ShareCount"]!=null && row["ShareCount"].ToString()!="") { model.ShareCount=int.Parse(row["ShareCount"].ToString()); } } return model; }
protected virtual Maticsoft.Model.StorePicturesTable BuildStorePicturesTable(Maticsoft.Model.BusPhotoAlbumTable busphotoAlbumTable, Maticsoft.Model.StorePicture storePicture) { var storePicturesTable = new Maticsoft.Model.StorePicturesTable { StorePicturesID = Guid.NewGuid().ToString(), BusPhotoAlbumID = busphotoAlbumTable.BusPhotoAlbumID, BusinessID = busphotoAlbumTable.BusinessID, PictureAddress = storePicture.PictureName, PicState = 2, UploadTime = DateTime.Now }; return storePicturesTable; }