public static IQueryable <ProductionLine> Project( this IQueryable <ProductionLine> query, ProductionLineQueryProjection projection) { foreach (var f in projection.GetFieldsArr()) { if (ProductionLineQueryProjection.MAPS.ContainsKey(f)) { foreach (var prop in ProductionLineQueryProjection.MAPS[f]) { query = query.Include(prop); } } } return(query); }
public IDictionary <string, object> GetProductionLineDynamic( ProductionLine row, ProductionLineQueryProjection projection, ProductionLineQueryOptions options) { var obj = new Dictionary <string, object>(); foreach (var f in projection.GetFieldsArr()) { switch (f) { case ProductionLineQueryProjection.INFO: { var entity = row; obj["id"] = entity.Id; obj["code"] = entity.Code; obj["info"] = entity.Info; var time = entity.CreatedTime .ToDefaultTimeZone(); var timeStr = time.ToString(options.date_format); obj["created_time"] = new { display = timeStr, iso = $"{time.ToUniversalTime():s}Z" }; time = entity.LastUpdated .ToDefaultTimeZone(); timeStr = time.ToString(options.date_format); obj["last_updated"] = new { display = timeStr, iso = $"{time.ToUniversalTime():s}Z" }; obj["disabled"] = entity.Disabled; } break; case ProductionLineQueryProjection.SELECT: { var entity = row; obj["id"] = entity.Id; obj["code"] = entity.Code; obj["disabled"] = entity.Disabled; } break; } } return(obj); }