Пример #1
0
        /// <summary>
        /// Return a composite object of various data.
        /// </summary>
        /// <param name="inputValue">
        /// The input value to pass to the database.
        /// </param>
        /// <returns>
        /// A new CompositeResultObject containing the data.
        /// </returns>
        internal CompositeResultObject GetCompositeResult(string inputValue)
        {
            MultiDataSetStoredProcedure storedProcedure = new MultiDataSetStoredProcedure(inputValue);

            using (StoredProcedureDataSetReader reader = ExecuteProcedureReader(storedProcedure))
            {
                TestRowOne[]   rowOnes   = reader.GetDataSetList <TestRowOne>();
                TestRowTwo[]   rowTwos   = reader.GetDataSetList <TestRowTwo>();
                TestRowThree[] rowThrees = reader.GetDataSetList <TestRowThree>();
                reader.ProcessOutputParameters();
                return(new CompositeResultObject(rowOnes, rowTwos, rowThrees, storedProcedure.GuidOutput));
            }
        }
Пример #2
0
 /// <summary>
 /// Gets all referendums from the database excluding answer and voter rows.
 /// </summary>
 /// <returns>
 /// An array of all referendums from the database.
 /// </returns>
 public Referendum[] GetAll()
 {
     using (StoredProcedureDataSetReader reader = ExecuteProcedureReader(new ReferendumGetAllStoredProcedure()))
     {
         ReferendumGetSummaryRow[] summaryRows = reader.GetDataSetList <ReferendumGetSummaryRow>();
         if (summaryRows == null)
         {
             return(null);
         }
         ReferendumGetAnswerRow[] answerRows = reader.GetDataSetList <ReferendumGetAnswerRow>();
         ReferendumGetVoterRow[]  voterRows  = reader.GetDataSetList <ReferendumGetVoterRow>();
         return(summaryRows.Select(r => new Referendum(r.Id, r.StartTime, r.EndTime, r.Question, answerRows.Where(ar => ar.Id == r.Id).Select(ar => ar.Answer).ToArray(), voterRows.Where(vr => vr.Id == r.Id).Select(vr => new Voter(vr.Address, vr.VoteCount, vr.Vote, vr.SignedVoteMessage)).ToArray(), r.CreateTime)).ToArray());
     }
 }
Пример #3
0
 /// <summary>
 /// Gets a referendum from the database based on its unique ID.
 /// </summary>
 /// <param name="id">
 /// The ID of the referendum to get.
 /// </param>
 /// <returns>
 /// The specified referendum if found, otherwise null.
 /// </returns>
 public Referendum Get(int id)
 {
     using (StoredProcedureDataSetReader reader = ExecuteProcedureReader(new ReferendumGetStoredProcedure(id)))
     {
         ReferendumGetSummaryRow summaryRow = reader.GetDataSetRow <ReferendumGetSummaryRow>();
         if (summaryRow == null)
         {
             return(null);
         }
         ReferendumGetAnswerRow[] answerRows = reader.GetDataSetList <ReferendumGetAnswerRow>();
         ReferendumGetVoterRow[]  voterRows  = reader.GetDataSetList <ReferendumGetVoterRow>();
         return(new Referendum(id, summaryRow.StartTime, summaryRow.EndTime, summaryRow.Question, answerRows == null ? null : answerRows.Select(ar => ar.Answer).ToArray(), voterRows == null ? null : voterRows.Select(vr => new Voter(vr.Address, vr.VoteCount, vr.Vote, vr.SignedVoteMessage)).ToArray(), summaryRow.CreateTime));
     }
 }