private ResourceQueryRow ProcessMultiResults(DynamicSql query, object[] objs) { var row = new ResourceQueryRow(); for (var i = 0; i < query.MultiResults.Count; i++) { var r = query.MultiResults[i]; switch (r.Key) { case ResourceQueryProjection.INFO: row.Resource = objs[i] as ResourceQueryResult; break; case ResourceQueryProjection.AREA: row.Area = objs[i] as AreaRelationship; break; case ResourceQueryProjection.CONTENT: row.Content = objs[i] as ResourceContentRelationship; break; case ResourceQueryProjection.OWNER: row.Owner = objs[i] as OwnerRelationship; break; case ResourceQueryProjection.LOCATION: row.Location = objs[i] as LocationRelationship; break; } } return(row); }
public IDictionary <string, object> GetResourceDynamic( ResourceQueryRow row, ResourceQueryProjection projection, ResourceQueryOptions options) { var obj = new Dictionary <string, object>(); foreach (var f in projection.GetFieldsArr()) { switch (f) { case ResourceQueryProjection.INFO: { var entity = row.Resource; obj["archived"] = entity.Archived; obj["area_id"] = entity.AreaId; obj["building_id"] = entity.BuildingId; obj["code"] = entity.Code; obj["floor_id"] = entity.FloorId; obj["id"] = entity.Id; obj["image_url"] = entity.ImageUrl; obj["location_id"] = entity.LocationId; obj["logo_url"] = entity.LogoUrl; obj["owner_id"] = entity.OwnerId; obj["phone"] = entity.Phone; obj["type_id"] = entity.TypeId; } break; case ResourceQueryProjection.CONTENT: { var entity = row.Content; if (entity != null) { obj["content_id"] = entity.Id; obj["lang"] = entity.Lang; obj["name"] = entity.Name; obj["description"] = entity.Description; } } break; case ResourceQueryProjection.CONTENT_CONTENT: { var entity = row.Content; if (entity != null) { obj["content"] = entity.Content; } } break; case ResourceQueryProjection.LOCATION: { var entity = row.Location; obj["location"] = new { id = entity.Id, code = entity.Code, name = entity.Name, }; } break; case ResourceQueryProjection.AREA: { var entity = row.Area; obj["area"] = new { id = entity.Id, code = entity.Code, name = entity.Name, }; } break; case ResourceQueryProjection.OWNER: { var entity = row.Owner; obj["owner"] = new { id = entity.Id, code = entity.Code, name = entity.Name, }; } break; case ResourceQueryProjection.CATEGORIES: { var entities = row.Resource.CategoriesOfResources; obj["categories"] = entities?.Select(o => { var cate = o.Category; var content = o.CategoryContent; return(new { id = cate.Id, archived = cate.Archived, content_id = content.Id, name = content.Name, lang = content.Lang }); }).ToList(); } break; } } return(obj); }