Beispiel #1
0
        /// <summary>
        /// NOTE: T should be the first type of data set returned by the query / procedure
        /// NOTE: U should be the second type of data set returned by the query / procedure
        /// MEANS that the generic classes should be passed in the order that is expected to be returned by the query.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <typeparam name="U"></typeparam>
        /// <param name="storedProcedure"></param>
        /// <returns>returns a class with List<T> AND List<U> as public properties</returns>
        internal async Task <GenericTwoListModel> LoadStaticDataTwoSetsAsync <T, U>
            (string storedProcedure)
        {
            var genericTwoList = new GenericTwoListModel();
            var returnData     = genericTwoList.GetLists <T, U>();

            List <T> ListT = null;
            List <U> ListU = null;

            using (IDbConnection connection = new SqlConnection(helper.GetConnectionString()))
            {
                using (var lists = await connection.QueryMultipleAsync(storedProcedure, CommandType.StoredProcedure))
                {
                    ListT = lists.Read <T>().ToList();
                    ListU = lists.Read <U>().ToList();
                }
            }

            returnData.T1 = ListT;
            returnData.U1 = ListU;
            return(returnData);
        }