Пример #1
0
        public async Task <UserInfoDto> GetCurrentUse(string Id)
        {
            using (var connect = DapperHandle.OpenConnection())
            {
                var sql = $"select * from SystemUser where Id=@id";

                return(await connect.QueryFirstAsync <UserInfoDto>(sql, new { id = Id }));
            }
        }
Пример #2
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));
            }
        }