/// <summary> /// 得到一个对象实体 /// </summary> public AndroidMvcServer.Model.Tb_Group DataRowToModel(DataRow row) { AndroidMvcServer.Model.Tb_Group model = new AndroidMvcServer.Model.Tb_Group(); if (row != null) { if (row["groupId"] != null) { model.groupId = row["groupId"].ToString(); } if (row["groupName"] != null) { model.groupName = row["groupName"].ToString(); } if (row["groupDesc"] != null) { model.groupDesc = row["groupDesc"].ToString(); } if (row["groupOwner"] != null) { model.groupOwner = row["groupOwner"].ToString(); } if (row["groupIcon"] != null && row["groupIcon"].ToString() != "") { model.groupIcon = int.Parse(row["groupIcon"].ToString()); } if (row["members"] != null) { model.members = row["members"].ToString(); } if (row["allowInvite"] != null && row["allowInvite"].ToString() != "") { model.allowInvite = int.Parse(row["allowInvite"].ToString()); } if (row["membersSize"] != null && row["membersSize"].ToString() != "") { model.membersSize = int.Parse(row["membersSize"].ToString()); } if (row["maxUsers"] != null && row["maxUsers"].ToString() != "") { model.maxUsers = int.Parse(row["maxUsers"].ToString()); } if (row["isPublic"] != null && row["isPublic"].ToString() != "") { model.isPublic = int.Parse(row["isPublic"].ToString()); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public AndroidMvcServer.Model.Tb_Group GetModel(string groupId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select groupId,groupName,groupDesc,groupOwner,groupIcon,members,allowInvite,membersSize,maxUsers,isPublic from tb_group "); strSql.Append(" where groupId=@groupId "); MySqlParameter[] parameters = { new MySqlParameter("@groupId", MySqlDbType.VarChar,50) }; parameters[0].Value = groupId; AndroidMvcServer.Model.Tb_Group model = new AndroidMvcServer.Model.Tb_Group(); DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }