public override string ToString()
        {
            SparqlQuery query = new SparqlQuery(SparqlSerializer.Serialize(_model, _query));

            query.Model = _model;

            return(query.ToString());
        }
        public IEnumerable <T> GetResources <T>(int offset = -1, int limit = -1) where T : Resource
        {
            _query.Offset = offset;
            _query.Limit  = limit;

            if (_inferenceEnabled)
            {
                SparqlQuery uriQuery = new SparqlQuery(SparqlSerializer.Serialize(_model, _query, true));

                StringBuilder uris    = new StringBuilder();
                var           uriList = FetchUris(uriQuery).ToList();

                foreach (Uri u in uriList)
                {
                    if (u != null)
                    {
                        uris.Append(SparqlSerializer.SerializeUri(u));
                    }
                }

                if (!uriList.Any())
                {
                    return(new List <T>());
                }

                SparqlQuery        query = new SparqlQuery(string.Format("DESCRIBE {0} {1}", uris, SparqlSerializer.GenerateDatasetClause(_model)));
                ISparqlQueryResult res   = _model.ExecuteQuery(query);

                if (IsSorted)
                {
                    return(res.GetResources <T>().OrderBy(o => { return (o != null) ? uriList.IndexOf(o.Uri) : -1; }));
                }
                else
                {
                    return(res.GetResources <T>());
                }
            }
            else
            {
                SparqlQuery query = new SparqlQuery(SparqlSerializer.Serialize(_model, _query));

                return(_model.ExecuteQuery(query, _inferenceEnabled).GetResources <T>());
            }
        }
Example #3
0
 public override string ToString()
 {
     return(SparqlSerializer.Serialize(null, this));
 }