• 实战技术总结


    1.选择单一条记录

       var Prize = con.Prizes.Where(e => e.PrizeType == 0).Select(p => new { id = Guid.NewGuid(), P = p }).OrderByDescending(p => p.id).FirstOrDefault().P;

    2.提示

    AjaxResult 文件:

        public class AjaxResult
        {
            public int Status { get; set; }
            public string Message { get; set; }
        }
        public class AjaxResult<T> : AjaxResult
        {
            public T Data { get; set; }
        }

    引用:

     AjaxResult<ScratchModel> result = new AjaxResult<ScratchModel>
                {
                    Status = -1,
                    Message = "您没有中奖,欢迎下次再来。",
                    Data = new ScratchModel
                    {
                        Category = 0,
                        PrizeScore = 0,
                        PrizeTitle = null,
                        PrizeDescription = null,
                        ImageURL = null
                    }
                };

    model 类型:

        public class ScratchModel
        {
            public PrizeCategory Category { get; set; }
            public int PrizeScore { get; set; }
            public string PrizeTitle { get; set; }
            public string PrizeDescription { get; set; }
            public string ImageURL { get; set; }
        }

    3.SQl

     string sql = string.Format("select  Name,Point from UserPointsByPointSource where PointSource={0} and UserId='{1}'", (int)PointSource.Friend, UserProfile.Id);
     model.UserPoints = context.Database.SqlQuery<UserPoints>(sql, new object[] { }).FirstOrDefault();

    4. SQL 语句

    获取前10 条去重复ID

      select top 10 UserId, max(CreateTime) as MaxTime  from UserPrizes  group  by UserId order by MaxTime  desc

    select top 10 C.Id,C.Name,C.HeadImage  from (
     select top 50 k.UserId,max(k.CreateTime) as MaxTime  from
    (
       select u.UserId,u.CreateTime from
       (
          select  UserId,PrizeId,CreateTime from  UserPrizes
        ) u  left join Prizes p on u.PrizeId=p.Id  where p.Category=4 and u.UserId is not null
    )k   group  by k.UserId order by MaxTime  desc
    ) t  left  join CPCUsers c  on t.UserId=c.Id  where c.Id is not null

  • 相关阅读:
    夜神模拟器+seleinm抓取手机app(参考资料集合)
    关于pycharm导入其他项目时出现找不到python无法运行的问题
    关于动态规划的一点研究
    numpy里的randn
    关于pandas里面的合并
    笛卡尔乘积的解释
    Python链表与反链表
    年度总结一下
    Docker的使用初探(一):常用指令说明
    Java开发学习心得(三):项目结构
  • 原文地址:https://www.cnblogs.com/hanxingli/p/5784571.html
Copyright © 2020-2023  润新知