zoukankan      html  css  js  c++  java
  • 实战技术总结

    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

  • 相关阅读:
    Sqlite官方的查询优化文档
    VC++动态链接库(DLL)编程深入浅出(三)转
    用Python查询手机号码归属地
    Delphi使用迅雷的开放下载引擎下载
    Android基础之一
    VC++动态链接库深入浅出(转)
    在Python脚本中使用Delphi控件
    Python与其他语言结合的参数转换函数PyArg_ParseTuple()
    设计模式之模板方法模式(Template)
    设计模式之简单工厂模式(Simple Factory)
  • 原文地址:https://www.cnblogs.com/hanxingli/p/5784571.html
Copyright © 2011-2022 走看看