public IHttpActionResult GeneralQuery([FromUri] GeneralQueryBm uspParams) { foreach (var _uspParam in uspParams.GetType().GetProperties()) { if (_uspParam.GetValue(uspParams) == null) { _uspParam.SetValue(uspParams, ""); } } // 传入下拉类别类型 List <SqlParameter> paramArray = new List <SqlParameter>(); paramArray.Add(new SqlParameter("@type", uspParams.type)); paramArray.Add(new SqlParameter("@param2", uspParams.param2)); paramArray.Add(new SqlParameter("@param3", uspParams.param3)); paramArray.Add(new SqlParameter("@param4", uspParams.param4)); paramArray.Add(new SqlParameter("@param5", uspParams.param5)); try { var dynamicDbSet = DynamicSqlQuery(YdmDb.Database, "EXEC [dbo].[usp_prdAppGeneralQuery] @type,@param2,@param3,@param4,@param5", paramArray.ToArray()); return(Json(dynamicDbSet)); } catch (Exception e) { var resp = new HttpResponseMessage(HttpStatusCode.NotFound) { Content = new StringContent(e.Message), ReasonPhrase = "存储过程异常" }; log.Error(e.Message); throw new HttpResponseException(resp); } }
public IHttpActionResult GeneralQuery([FromUri] GeneralQueryBm p) { foreach (var _uspParam in p.GetType().GetProperties()) { if (_uspParam.GetValue(p) == null) { _uspParam.SetValue(p, ""); } } List <SqlParameter> paramArray = new List <SqlParameter>(); paramArray.Add(new SqlParameter("@type", p.type)); paramArray.Add(new SqlParameter("@param2", p.param2)); paramArray.Add(new SqlParameter("@param3", p.param3)); paramArray.Add(new SqlParameter("@param4", p.param4)); paramArray.Add(new SqlParameter("@param5", p.param5)); try { var dynamicDbSet = DynamicSqlQueryClass.Instance.DynamicSqlQuery(fnmDb.Database, "EXEC [dbo].[usp_prdFnGeneralQuery] @type,@param2,@param3,@param4,@param5", paramArray.ToArray()); return(Json(dynamicDbSet, JsonFormatSettings.Instance.GetSettings())); } catch (Exception e) { var resp = new HttpResponseMessage(HttpStatusCode.NotFound) { Content = new StringContent(e.Message) }; log.Error(e.Message); throw new HttpResponseException(resp); } }