Method ExecuteReaderCQ
ExecuteReaderCQ(ContinuousQuery)
Opens ExecuteReader(String, IDictionary, Boolean, Int32) on server nodes to execute query, also registers continous query call backs for data, that falls on query's criteria; if any changes occur in that data.
Declaration
[TargetMethod(1)]
public virtual ICacheReader ExecuteReaderCQ(ContinuousQuery cquery)
Parameters
Type | Name | Description |
---|---|---|
ContinuousQuery | cquery | simple SQL like query syntax to query objects from cache |
Returns
Type | Description |
---|---|
ICacheReader | Returns a cache reader of first chunk of data on execution of data reader |
Examples
These operators are supported by NCache Queries.
- Comparison Operators = , == , != , <> , < , > , <=, >=, IN
- Logical Operators AND , OR , NOT
- Miscellaneous () , DateTime.Now , DateTime("any date time compatible string")
Cache _cache = NCache.InitializeCache("mycache");
product1 = new Product(3, "Tunnbr?d", "", 4, 2); product2 = new Product(4, "Tunnbr?d", "", 5, 9); string qry = "SELECT Product WHERE this.ProductQuantity = ?;" Hashtable indexTable = new Hashtable(); indexTable.Add("ProductQuantity", 9); ContinuousQuery cQuery = new ContinuousQuery(qry, indexTable);
_cache.Add("2202", product1); _cache.Add("2203", product2); cQuery.RegisterNotification(new QueryDataNotificationCallback(QueryItemCallBack), EventType.ItemUpdated | EventType.ItemRemoved, EventDataFilter.None);
ICacheReader reader = _cache.ExecuteReaderCQ(cQuery); if (reader.FieldCount > 0) { while (reader.Read()) { object category = reader.GetValue(0); //perform operations } } else { //perform operations } reader.Close();
public void QueryItemCallBack(string key, CQEventArg arg) { switch (arg.EventType) { case EventType.ItemRemoved: //do something break; case EventType.ItemUpdated: //do something break; case EventType.ItemAdded: //do something break; } }
ExecuteReaderCQ(ContinuousQuery, Boolean)
Opens ExecuteReader(String, IDictionary, Boolean, Int32) on server nodes to execute query, also registers continous query call backs for data, that falls on query's criteria; if any changes occur in that data.
Declaration
[TargetMethod(2)]
public virtual ICacheReader ExecuteReaderCQ(ContinuousQuery cquery, bool getData)
Parameters
Type | Name | Description |
---|---|---|
ContinuousQuery | cquery | simple SQL like query syntax to query objects from cache |
System.Boolean | getData | Flag to recieve the values/data alongwith keys |
Returns
Type | Description |
---|---|
ICacheReader | Returns a cache reader of first chunk of data on execution of data reader |
Examples
These operators are supported by NCache Queries.
- Comparison Operators = , == , != , <> , < , > , <=, >=, IN
- Logical Operators AND , OR , NOT
- Miscellaneous () , DateTime.Now , DateTime("any date time compatible string")
Cache _cache = NCache.InitializeCache("mycache");
product1 = new Product(3, "Tunnbr?d", "", 4, 2); product2 = new Product(4, "Tunnbr?d", "", 5, 9); string qry = "SELECT Product WHERE this.ProductID = ?;" Hashtable indexTable = new Hashtable(); indexTable.Add("ProductID", 4); ContinuousQuery cQuery = new ContinuousQuery(qry, indexTable);
_cache.Add("2202", product1); _cache.Add("2203", product2); cQuery.RegisterNotification(new QueryDataNotificationCallback(QueryItemCallBack), EventType.ItemUpdated | EventType.ItemRemoved, EventDataFilter.None);
ICacheReader reader = _cache.ExecuteReaderCQ(cQuery,true);
if (reader.FieldCount > 0) { while (reader.Read()) { object category = reader.GetValue(0); //perform operations } } else { //perform operations } reader.Close();
public void QueryItemCallBack(string key, CQEventArg arg) { switch (arg.EventType) { case EventType.ItemRemoved: //do something break; case EventType.ItemUpdated: //do something break; case EventType.ItemAdded: //do something break; } }
ExecuteReaderCQ(ContinuousQuery, Boolean, Int32)
Opens ExecuteReader(String, IDictionary, Boolean, Int32) on server nodes to execute query, also registers
Declaration
[TargetMethod(3)]
public virtual ICacheReader ExecuteReaderCQ(ContinuousQuery query, bool getData, int chunkSize)
Parameters
Type | Name | Description |
---|---|---|
ContinuousQuery | query | simple SQL like query syntax to query objects from cache |
System.Boolean | getData | Flag to recieve the values/data alongwith keys |
System.Int32 | chunkSize | Size of data/keys packets recieved after search, default value is 512 * 1024 kb's |
Returns
Type | Description |
---|---|
ICacheReader | Returns a cache reader of first chunk of data on execution of data reader |
Examples
These operators are supported by NCache Queries.
- Comparison Operators = , == , != , <> , < , > , <=, >=, IN
- Logical Operators AND , OR , NOT
- Miscellaneous () , DateTime.Now , DateTime("any date time compatible string")
Cache _cache = NCache.InitializeCache("mycache");
product1 = new Product(3, "Tunnbr?d", "", 4, 2); product2 = new Product(4, "Tunnbr?d", "", 5, 9); string qry = "SELECT Product where this.ProductName = ?"; Hashtable indexTable = new Hashtable(); indexTable.Add("ProductName", "Tunnbr?d"); ContinuousQuery cQuery = new ContinuousQuery(qry, indexTable);
_cache.Add("2202", product1); _cache.Add("2203", product2);
cQuery.RegisterNotification(new QueryDataNotificationCallback(QueryItemCallBack), EventType.ItemUpdated | EventType.ItemRemoved, EventDataFilter.None);
ICacheReader reader = _cache.ExecuteReaderCQ(cQuery,true,50); if (reader.FieldCount > 0) { while (reader.Read()) { object category = reader.GetValue(0); //perform operations } } else { //perform operations } reader.Close();
public void QueryItemCallBack(string key, CQEventArg arg) { switch (arg.EventType) { case EventType.ItemRemoved: //do something break; case EventType.ItemUpdated: //do something break; case EventType.ItemAdded: //do something break; } }