zoukankan      html  css  js  c++  java
  • EF 数据查询(更改默认排序)

    数据实体对象

    public class ProductInvLocationMapEntity:BaseDomain
        {
            #region Constructors
    
            public ProductInvLocationMapEntity()
            { }
    
            #endregion
    
            #region Properties
            /// <summary>
            /// 
            /// AllowNull: False
            /// Length: 8
            /// </summary>
            //public long Id { get; set; }
    
            /// <summary>
            /// 商品id
            /// AllowNull: False
            /// Length: 8
            /// </summary>
            public long ProductId { get; set; }
    
            /// <summary>
            /// 商品货号
            /// AllowNull: False
            /// Length: 50
            /// </summary>
            public string ProductCode { get; set; }
    
            /// <summary>
            /// 库位编号
            /// AllowNull: False
            /// Length: 50
            /// </summary>
            public string LocationLabel { get; set; }
    
            /// <summary>
            /// 库位类型
            /// AllowNull: False
            /// Length: 50
            /// </summary>
            public string LocationType { get; set; }
    
            /// <summary>
            /// 生产日期
            /// AllowNull: False
            /// Length: 8
            /// </summary>
            public DateTime ManufactureDate { get; set; }
    
            /// <summary>
            /// 已存放数量
            /// AllowNull: False
            /// Length: 4
            /// </summary>
            public int StoredQty { get; set; }
    
            
    
    
    
            #endregion
    
            #region override Mehtods
    
            public override string ToString()
            {
                return base.ToString();
            }
    
            #endregion
    
            /// <summary>
            /// 仓库Id
            /// </summary>
            public long WarehouseId { get; set; }
        }

    数据操作方法

    /// <summary>
            /// 
            /// </summary>
            /// <param name="product_id"></param>
            /// <param name="manufacture_date"></param>
            /// <returns></returns>
            public Models.EF6_Test.ProductInvLocationMapEntity GetMatchedLocationMap(long product_id,DateTime manufacture_date)
            {
    
                DateTime maxValue = new DateTime(9999, 12, 31, 23, 59, 59);
    #if DEBUG
                this.OpenSqlRawOutput(Console.WriteLine);
    #endif
                var matched_entity = this.EntrySet
                    .OrderBy(obj=>obj.ModifiedTime)
                    .FirstOrDefault(obj => (obj.ProductId == product_id && obj.ManufactureDate == manufacture_date) || (obj.ProductId == product_id && obj.ManufactureDate == maxValue));
                return matched_entity;
            }










  • 相关阅读:
    sqlserver 中数据类型bit的使用 Followyour
    如何在保证睡眠的情况把各种事情做好
    求职具备八大素质
    提高效率的5条黄金法则
    随笔摘录:世上只有一件东西,能始终经受住生活的冲击:一颗宁静的心。
    Hadoop中文文档 (0.19.0)
    两个微型的Map/Reduce框架: FileMap(FM)和BashReduce
    Hadoop的商业化支持
    Yahoo的Hadoop版本
    Map/Reduce and Queues for MySQL Using Gearman
  • 原文地址:https://www.cnblogs.com/xakml/p/7049086.html
Copyright © 2011-2022 走看看