using System;
using System.Linq.Expressions;
using System.Collections.Generic;
using DapperORM;
using DapperORM.Common.Models;
using PushInfo.Core.Models.Tables;
using PushInfo.Core.IDAL;
using PushInfo.Core.Models.QueryResults;
using System.Data;
using PushPlatform.Common.Enumerate;

namespace PushInfo.Core.DAL.MySql
{
    public class QueryProcOrSqlDAL : BaseRepository<DataMessage>
    {
        public ResultModelDataSet GetPushValue(string sql,string projectId, PushActionType type)
        {
            Dictionary<string, object> param = new Dictionary<string, object>();
            param.Add("@projectID", projectId);
            return QueryProcOrSql(sql, param, type);
        }
            
        /// <summary>
        /// 查询存储过程
        /// </summary>
        /// <param name="procName"></param>
        /// <param name="param"></param>
        /// <returns></returns>
        public ResultModelDataSet QueryProcOrSql(string sql, Dictionary<string,object> param, PushActionType type)
        {
            if(type == PushActionType.存储过程)
            {
                return QueryDataSetAysnc(sql, param, null, CommandType.StoredProcedure).Result;
            }
            else
            {
                return QueryDataSetAysnc(sql, param, null, CommandType.Text).Result;
            }

        }
    }
}
