Exemplo n.º 1
0
        public async Task <List <HostilityListDto> > GetAllHostility(QueryHostilityDto dto)
        {
            using (var connection = DapperHandle.OpenConnection())
            {
                var sqlstr = @"select HostilityId,QQNumber,HostilityName,RoleLevel,
                               MilitaryPower,HostilityLevel,IsSurpass,Remark,CreateTime 
                               from Hostility where 1=1";

                //模仿城里人微软的玩法
                var(sql, param) = DapperHandle.CreateQueryHandle(sqlstr, dto)
                                  .AddCondition(a => !string.IsNullOrEmpty(a.QQNumber), " and QQNumber like @QQNumber")
                                  .AddCondition(a => !string.IsNullOrEmpty(a.HostilityName), " and HostilityName like @HostilityName")
                                  .BuilderPage(orderby: "HostilityId");

                return((List <HostilityListDto>) await connection.QueryAsync <HostilityListDto>(sql, param));
            }
        }
Exemplo n.º 2
0
 public async Task <ActionResult> GetHostilityInfo([FromQuery] QueryHostilityDto dto)
 {
     return(Ok(await _hostilityService.GetAllHostility(dto)));
 }