📄 query.cs
字号:
namespace Perst
{
using System;
#if USE_GENERICS
using System.Collections.Generic;
#else
using System.Collections;
#endif
/// <summary>
/// Class representing JSQL query. JSQL allows to select members of Perst collections
/// using SQL like predicate. Almost all Perst collections have select() method
/// which execute arbitrary JSQL query. But it is also possible to create Query instance explicitely,
/// Using storage.createQuery class. In this case it is possible to specify query with parameters,
/// once prepare query and then multiple times specify parameters and execute it.
/// Also Query interface allows to specify <i>indices</i> and <i>resolvers</i>.
/// JSQL can use arbitrary Perst <code>GenericIndex</code> to perform fast selection if object
/// instead of sequeial search. And user provided <i>resolver</i> allows to substitute SQL joins.
/// </summary>
#if USE_GENERICS
public interface Query<T>
#else
public interface Query
#endif
{
#if USE_GENERICS
/// <summary> Execute query
/// </summary>
/// <param name="e">enumerable collection for sequential access to objects in the table
/// </param>
/// <param name="predicate">selection crieria
/// </param>
/// <returns>
/// iterator through selected objects
/// </returns>
IEnumerable<T> Select(IEnumerable<T> e, string predicate);
/// <summary> Prepare SQL statement
/// </summary>
/// <param name="predicate">selection crieria with '?' placeholders for parameter value
/// </param>
void Prepare(string predicate);
/// <summary> Execute prepared query
/// </summary>
/// <param name="iterator">iterator for sequential and direct access to objects in the table
/// </param>
/// <returns> iterator through selected objects
/// </returns>
IEnumerable<T> Execute(IEnumerable<T> iterator);
#else
/// <summary> Execute query
/// </summary>
/// <param name="cls">class of inspected objects
/// </param>
/// <param name="e">enumerable collection for sequential access to objects in the table
/// </param>
/// <param name="predicate">selection crieria
/// </param>
/// <returns>
/// iterator through selected objects
/// </returns>
IEnumerable Select(Type cls, IEnumerable e, string predicate);
/// <summary> Execute query
/// </summary>
/// <param name="className">name of the class of inspected objects
/// </param>
/// <param name="e">enumerable collection for sequential access to objects in the table
/// </param>
/// <param name="predicate">selection crieria
/// </param>
/// <returns> iterator through selected objects
/// </returns>
IEnumerable Select(string className, IEnumerable e, string predicate);
/// <summary> Prepare SQL statement
/// </summary>
/// <param name="cls">class of iterated objects
/// </param>
/// <param name="predicate">selection crieria with '?' placeholders for parameter value
/// </param>
void Prepare(Type cls, string predicate);
/// <summary> Prepare SQL statement
/// </summary>
/// <param name="className">name of the class of iterated objects
/// </param>
/// <param name="predicate">selection crieria with '?' placeholders for parameter value
/// </param>
void Prepare(string className, string predicate);
/// <summary> Execute prepared query
/// </summary>
/// <param name="iterator">iterator for sequential and direct access to objects in the table
/// </param>
/// <returns> iterator through selected objects
/// </returns>
IEnumerable Execute(IEnumerable iterator);
#endif
/// <summary>Set or get value of query parameter
/// </summary>
/// <param name="i">parameters index (1 based)
/// </param>
object this[int i]
{
get;
set;
}
/// <summary> Enable or disable reporting of runtime errors on console.
/// Runtime errors during JSQL query are reported in two ways:
/// <OL>
/// <LI>If query error reporting is enabled then message is printed to System.err</LI>
/// <LI>If storage listener is registered, then JSQLRuntimeError of method listener is invoked</LI>
/// </OL>
/// By default reporting to System.err is enabled.
/// </summary>
/// <param name="enabled">if <code>true</code> then reportnig is enabled
/// </param>
void EnableRuntimeErrorReporting(bool enabled);
/// <summary> Specify resolver. Resolver can be used to replaced SQL JOINs: given object ID,
/// it will provide reference to the resolved object
/// </summary>
/// <param name="original">class which instances will have to be resolved
/// </param>
/// <param name="resolved">class of the resolved object
/// </param>
/// <param name="resolver">class implementing Resolver interface
/// </param>
void SetResolver(Type original, Type resolved, Resolver resolver);
/// <summary> Add index which can be used to optimize query execution (replace sequential search with direct index access)
/// </summary>
/// <param name="key">indexed field
/// </param>
/// <param name="index">implementation of index
/// </param>
#if USE_GENERICS
void AddIndex(string key, GenericKeyIndex<T> index);
#else
void AddIndex(string key, GenericIndex index);
#endif
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -