示例#1
0
        public static async Task <IEnumerable <dynamic> > GetViewColumns(string ViewName, string ViewKey)
        {
            IEnumerable <dynamic> columns = null;

            using (var connection = new ConnectionProvider(ApiService.Site).CreateDbConnection())
            {
                string UserId = ApiService.UserId;
                try
                {
                    // get columns
                    connection.Open();
                    int recCnt = await connection.ExecuteScalarAsync <int>(qryViewMaster.selectColDefCnt, new { ViewName, UserId });

                    if (recCnt > 0)
                    {
                        columns = await connection.QueryAsync(qryViewMaster.selectViewColumns, new { ViewName, UserId });
                    }
                    else
                    {
                        columns = await connection.QueryAsync(qryViewMaster.selectDefaultColumns, new { ViewName });
                    }
                }
                catch (Exception) { throw; }
                finally { connection.Close(); }
            }

            return(columns);
        }