Esempio n. 1
0
        /// <summary>
        /// Handler for the special case query that selects a specific instance of a type
        /// </summary>
        /// <typeparam name="T">The entity type to create for then instance if it is found</typeparam>
        /// <param name="instanceIdentifier">The identifier for the instance</param>
        /// <param name="typeIdentifier">The identifier for the type that the instance must be an instance of</param>
        /// <returns>An enumerable that returns 0 or 1 instances of <typeparamref name="T"/>. If the resource identified
        /// by <paramref name="instanceIdentifier"/> is an instance of the resource identifier by <paramref name="typeIdentifier"/>,
        /// the enumeration returns a single object, otherwise it returns no objects.</returns>
        public override IEnumerable <T> ExecuteInstanceQuery <T>(string instanceIdentifier, string typeIdentifier)
        {
            var sparqlQuery = String.Format("ASK {0} {{ <{1}> a <{2}>. }}", _store.GetDatasetClause(), instanceIdentifier, typeIdentifier);


            var sparqResult = _store.ExecuteSparql(sparqlQuery);
            var resultDoc   = sparqResult.ResultDocument;

            if (resultDoc.SparqlBooleanResult())
            {
                var dataObject = _store.MakeDataObject(instanceIdentifier);
                yield return(BindDataObject <T>(dataObject, GetImplType(typeof(T))));
            }
            yield break;
        }