This project has moved and is read-only. For the latest updates, please go here.

Get an object from context by id (without determining the type)

Oct 1, 2014 at 12:06 PM
Hi there,

Is there a way to get from the context a DataObject by the id (BrightstarDB.EntityFramework.BrightstarEntityObject) ?

I would like to get the triples related to any object by its id, without having to determine the type. Instead if using SPARQL, is there a way to get the DataObject, and then I can access the BrightstarDB.Client.DataObject triples property.

Thanks!
Oct 2, 2014 at 10:15 AM
Hi,

Although the EntityFramework does use a DataObject internally, that is kept internal because the entity object also maintains a cache of property values taken from the triples in the DataObject and we don't want those two things getting out of sync.

I think the SPARQL route is the way to go - you can create a DataObjectStore then either use the GetDataObject() method to get the DataObject by its identity (remember this must be the full URI identifier), or you can use BindDataObjectsWithSparql to execute a SPARQL query and get an enumeration of the results as DataObject instances.

If you only want to list out the triples for a particular identity, then another alternative would be to use the low level APIs and construct your own SPARQL query to return the triples - something like:
SELECT ?p ?o WHERE { <foo> ?p ?o }
Then you can use the XDocument extensions to iterate over the results (see http://brightstardb.readthedocs.org/en/latest/RDF_Client_API/#querying-data-using-sparql and http://brightstardb.readthedocs.org/en/latest/RDF_Client_API/#using-extension-methods)
Marked as answer by techquila on 10/9/2014 at 12:26 PM
Oct 2, 2014 at 2:01 PM
Thank you :-) I used the low lever API eventually , thanks!