public static List <ChunkHashModel> GetChunksByFileId(int fileId) { List <ChunkHashModel> list = new List <ChunkHashModel>(); string sqlQuery = "SELECT * FROM chunk WHERE chunk.file_id=" + fileId; SqlDataReader dr = Database.Instance.GetDataReader(sqlQuery); while (dr.Read()) { ChunkHashModel chunk = new ChunkHashModel(dr); list.Add(chunk); } dr.Close(); return(list); }
public static byte[] GetChunkByChunkIdAndFileId(int chunkId, int fileId) { List <ChunkHashModel> list = new List <ChunkHashModel>(); string sqlQuery = "SELECT * FROM chunk WHERE chunk.file_id=" + fileId + " AND chunk.chunk_id=" + chunkId; SqlDataReader dr = Database.Instance.GetDataReader(sqlQuery); if (dr.Read()) { ChunkHashModel chunk = new ChunkHashModel(dr); dr.Close(); return(chunk.hash); } else { dr.Close(); return(null); } }