/// <summary>Tries to retrieve subjects from the backing RDF source for a dynamically resolved property.</summary> public override bool TryGetMember(GetMemberBinder binder, out object result) { _entity.EnsureIsInitialized(); var propertySpec = new DynamicPropertyAggregate(binder.Name); if (!propertySpec.IsValid) { result = null; return(false); } var property = Ontology.Properties.SingleOrDefault(p => p.Name == propertySpec.Name); if (property == null) { property = new Property(propertySpec.Name).InOntology(Ontology); } result = GetObjects(_entity.Id, property, propertySpec); if (propertySpec.IsList) { var graphOverride = new UnionGraphSelector(); var head = (IRdfListNode <object>) typeof(EntityExtensions).GetTypeInfo() .GetMethod("AsEntity") .MakeGenericMethod(typeof(IRdfListNode <object>)) .Invoke(null, new[] { result }); ((IEntityProxy)head.UnwrapProxy()).OverrideGraphSelection(graphOverride); var rdfListAdapter = new RdfListAdapter <IRdfListOwner, IRdfListNode <object>, object>(_entity.Context, _entity, head, graphOverride); result = new ReadOnlyCollection <dynamic>(rdfListAdapter); } return(true); }
internal object GetObjects(EntityId entityId, IProperty property, DynamicPropertyAggregate aggregate) { var objectValues = _tripleStore.GetObjectsForPredicate(entityId, property.Uri, null); var objects = objectValues.Select(ConvertObject); var aggregator = _resultTransformers.GetAggregator(aggregate.Aggregation); return(aggregator.Aggregate(objects)); }
internal IProperty GetProperty(string binderName) { var spec = new DynamicPropertyAggregate(binderName); return((from prop in Ontology.Properties where prop.Name == spec.Name select prop).SingleOrDefault()); }