XAP.NET 9.5 Documentation > Back to Table of Contents
Getting Partial Results Using The Projection API
Summary: This page describes how you can obtain partial results when querying the space to improve application performance and reduce memory footprint.
Overview
Specifying a Projection with your QueryProjections are supported using a SqlQuery or ID Queries. Below is a simple example that demonstrates reading a Person object where only the 'FirstName' and 'LastName' properties are returned with the query result array. All other Person properties will not be returned: public class Person { ... [SpaceId(AutoGenerate = false)] public Long Id {get; set;} public String FirstName {get; set;} public String LastName {get; set;} public String Address {get; set;} ... } ISpaceProxy space = //... obtain a space reference. Long id = //... obtain the space object ID. Person result = space.Read<Person>(new IdQuery<Person>(id) {Projections = new []{"FirstName", "LastName"}); With the above example a specific Person is being read but only its 'FirstName' and 'LastName' will contains values and all the other properties will contain a null value. You may use the same approach with the SqlQuery or IdsQuery: SqlQuery<Person> query = new SqlQuery<Person>("") {Projections = new []{"FirstName", "LastName"}); Person result[] = space.ReadMultiple(query); IdsQuery<Person> idsQuery = new IdsQuery<Person>(new Long[]{id1,id2}) {Projections = new []{"FirstName", "LastName"}; Person result[] = space.ReadByIds(idsQuery).ResultsArray; The SpaceDocument support projections as well: SqlQuery<SpaceDocument> docQuery = new SqlQuery<SpaceDocument>(typeof(Person).Name ,"") {Projections = new []{"FirstName", "LastName"}; SpaceDocument docresult[] = space.ReadMultiple(docQuery); Supported OperationsThe projection is defined for any operation that returns data from the space. Therefore ID Based or Query based operations support projections. You can use projections with Read,Take,ReadById,TakeById,ReadMultiple and TakeMultiple operations. When performing a Take operation with projections, the entire object will be removed from the space, but the result returned to the user will contain only the projected properties.
Considerations
|
![]() |
GigaSpaces.com - Legal Notice - 3rd Party Licenses - Site Map - API Docs - Forum - Downloads - Blog - White Papers - Contact Tech Writing - Gen. by Atlassian Confluence |