public IList<EBreakOilHistoryRecord> Search(IList<Guid> vehicleCodes, DateTime beginTime, DateTime endTime, int? commandType, int? commandState, string tenantCode, int rowIndex, int pageSize, out int totalRowCount) { using (IRepository repository = SessionManager.CreateRepository(typeof(EBreakOilHistoryRecord))) { Query query = new Query(typeof(EBreakOilHistoryRecord)); Expression expression = null; if (vehicleCodes != null && vehicleCodes.Count > 0) { expression = Expression.CreateExpression("VehicleCode", PolynaryOperatorType.In, vehicleCodes); } ExpressionUtility<DateTime>.AddExpression_Between("SetTime", beginTime, endTime, ref expression); if (commandState != -1) ExpressionUtility<int?>.AddExpression("CommandState", commandState, BinaryOperatorType.EqualTo, ref expression); if (commandType != 0) ExpressionUtility<int?>.AddExpression("CommandType", commandType, BinaryOperatorType.EqualTo, ref expression); query.Expression = expression; query.Projections.Add(Projection.RowCount()); totalRowCount = repository.Single<int>(query); query.Projections.Clear(); query.Index = rowIndex; query.Count = pageSize; query.Order = Order.Desc("VehicleCode") & Order.Desc("SetTime"); IList<EBreakOilHistoryRecord> list = repository.List<EBreakOilHistoryRecord>(query); if (list != null && list.Count > 0) { IVehicleService manager = new VehicleService(); manager.GetLincesePlate<EBreakOilHistoryRecord>(ref list); } foreach (EBreakOilHistoryRecord record in list) { decimal mileage = CalculateTotalMileage(record.GPSCode, record.StarkMileage); record.StarkMileage = mileage / 1000; } return list; } }