Dapper 参数化查询 ,随笔

Dapper 参数化查询:

 对于此种查询:id in(1,2,3,4) ,code in('a','b','c')    ,传参:List id  ,List code  .实列如下:

        public List GetChildListByIndexIds(int selfId, List indexIds)
        {
            DynamicParameters Parameters = new DynamicParameters();
            Parameters.Add("SelfId", selfId);
            Parameters.Add("indexIds", indexIds);
            string sql = @"SELECT a.id,a.IndexId,a.ChildId,a.Indexvalue_Code,a.Indexvalue
                        FROM [dbo].[Evaluation_SelfAssessment_details_Child] a WHERE a.SelfId=@SelfId AND a.IndexId IN @indexIds ";
            return _Respository.GetListWithSql(sql, Parameters);
        }

 

你可能感兴趣的:(随笔集)