public static List <AttributeCount> GetAttributeNoteCounts() { List <AttributeCount> attributeNoteCountList = new List <AttributeCount>(); string query = @"SELECT attributeID, COUNT(*) AS noteCount FROM attributetonote GROUP BY attributeID UNION ALL SELECT -1 AS attributeID, (SELECT COUNT(*) FROM notedb.notes WHERE noteID NOT IN (SELECT noteID FROM notedb.attributetonote)) AS noteCount"; MySqlCommand com = new MySqlCommand(query); com.CommandType = System.Data.CommandType.Text; DataTable dt = RunNotesQuery(com); foreach (DataRow r in dt.Rows) { AttributeCount ac = new AttributeCount(); ac.attributeID = Convert.ToInt32(r[0].ToString()); ac.noteCount = Convert.ToInt32(r[1].ToString()); attributeNoteCountList.Add(ac); } return(attributeNoteCountList); }
/// <summary> /// Convert the data of this class (all fields) into byte data. /// </summary> /// <returns>Byte data.</returns> public override byte[] GetBytes() { byte[] headbytes = new byte[HeadSize]; // !!!!Caution: keep the order of the following code lines!!!! var data = GetBytes(Signature, DataVersion.Bytes(), DataByteCount.Bytes(), StartClassId.Bytes(), ClassIdsCount.Bytes(), ClassIdsDataOffset.Bytes(), SchemaTypeCount.Bytes(), SchemaTypeDataOffset.Bytes(), ParticleCount.Bytes(), ParticleDataOffset.Bytes(), ParticleChildrenIndexCount.Bytes(), ParticleChildrenIndexDataOffset.Bytes(), AttributeCount.Bytes(), AttributeDataOffset.Bytes(), SimpleTypeCount.Bytes(), SimpleTypeDataOffset.Bytes()); data.CopyTo(headbytes, 0); return(headbytes); }