public static IQueryable <AppConfig> Project( this IQueryable <AppConfig> query, AppConfigQueryProjection projection) { foreach (var f in projection.GetFieldsArr()) { if (AppConfigQueryProjection.MAPS.ContainsKey(f)) { foreach (var prop in AppConfigQueryProjection.MAPS[f]) { query = query.Include(prop); } } } return(query); }
public IDictionary <string, object> GetAppConfigDynamic( AppConfig row, AppConfigQueryProjection projection, AppConfigQueryOptions options) { var obj = new Dictionary <string, object>(); foreach (var f in projection.GetFieldsArr()) { switch (f) { case AppConfigQueryProjection.INFO: { var entity = row; obj["id"] = entity.Id; obj["name"] = entity.Name; obj["client_id"] = entity.ClientId; obj["is_default"] = entity.IsDefault; 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" }; } break; case AppConfigQueryProjection.SELECT: { var entity = row; obj["id"] = entity.Id; obj["name"] = entity.Name; obj["is_default"] = entity.IsDefault; } break; } } return(obj); }