SmartSql 中 in (参数) 查询用法

 

    public dynamic GetTest( string testlist)
        {
            try
            {
                IList<int> test_list = new List<int> { 1, 2, 3 };
                IList<RoleMenu> lsit = chyUserService.SqlMapper.Query<RoleMenu>(new RequestContext
               {
                   Scope = nameof(User),
                   SqlId = "GetQueryTest",
                   Request = new { Id = test_list }
                });
                return lsit;
            }
            catch (Exception ex) 
            {

                throw ex;
            }
        }

对应的xml

  <Statement Id="GetQueryTest">
      SELECT * from  RoleMenu 
       <Where>
         MenuId in(
         <For Prepend=""  Property="Id" Separator="," >
              @Id
          </For>
       )
      </Where>
    </Statement>

 

posted @ 2020-12-25 00:38  剧里局外  阅读(218)  评论(0编辑  收藏  举报