Class QueryDescriptionExtensions
Query description extensions
Inherited Members
Namespace: XData.Mapping.Dynamic
Assembly: XData.docfx.dll
Syntax
public static class QueryDescriptionExtensions
Methods
| Improve this Doc View SourceAsPrimary<T>(T)
Set primary filter flag to filter description
Declaration
public static T AsPrimary<T>(this T desc)
where T : IFilterDescription
Parameters
Type | Name | Description |
---|---|---|
T | desc | Filter description |
Returns
Type | Description |
---|---|
T | Filter description |
Type Parameters
Name | Description |
---|---|
T | Filter description type |
Exceptions
Type | Condition |
---|---|
XDataRuntimeException | desc argument can not be null |
Case<T, TResult>(IQueryStructureAdapter, Expression<Func<IQueryStructureAdapter, T>>, Expression<Func<IQueryStructureAdapter, TResult>>, TaggedExpression<T, TResult>[])
Case
Declaration
public static TResult Case<T, TResult>(this IQueryStructureAdapter adapter, Expression<Func<IQueryStructureAdapter, T>> expression, Expression<Func<IQueryStructureAdapter, TResult>> elseValue, params TaggedExpression<T, TResult>[] switchValues)
Parameters
Type | Name | Description |
---|---|---|
IQueryStructureAdapter | adapter | Source query structure adapter |
Expression<Func<IQueryStructureAdapter, T>> | expression | Case expression |
Expression<Func<IQueryStructureAdapter, TResult>> | elseValue | Else value |
TaggedExpression<T, TResult>[] | switchValues | Case switch values |
Returns
Type | Description |
---|---|
TResult | Case result |
Type Parameters
Name | Description |
---|---|
T | |
TResult |
Exceptions
Type | Condition |
---|---|
XDataRuntimeException | Function accessible in XData LINQ expressions only |
DateDiff<T>(IQueryStructureAdapter, Expression<Func<IQueryStructureAdapter, DateTime>>, Expression<Func<IQueryStructureAdapter, DateTime>>, DateDiffKind)
Dates difference
Declaration
public static T DateDiff<T>(this IQueryStructureAdapter adapter, Expression<Func<IQueryStructureAdapter, DateTime>> finalDate, Expression<Func<IQueryStructureAdapter, DateTime>> startDate, DateDiffKind kind)
Parameters
Type | Name | Description |
---|---|---|
IQueryStructureAdapter | adapter | Source query structure adapter |
Expression<Func<IQueryStructureAdapter, DateTime>> | finalDate | Final date |
Expression<Func<IQueryStructureAdapter, DateTime>> | startDate | Start date |
DateDiffKind | kind | Dates differences kind |
Returns
Type | Description |
---|---|
T | Dates difference |
Type Parameters
Name | Description |
---|---|
T |
Exceptions
Type | Condition |
---|---|
XDataRuntimeException | Function accessible in XData LINQ expressions only |
Exists(IQueryStructureAdapter, String)
Exists
Declaration
public static bool Exists(this IQueryStructureAdapter adapter, string subQueryAlias)
Parameters
Type | Name | Description |
---|---|---|
IQueryStructureAdapter | adapter | Source query structure adapter |
String | subQueryAlias | Subquery alias |
Returns
Type | Description |
---|---|
Boolean |
Exceptions
Type | Condition |
---|---|
XDataRuntimeException | Function accessible in XData LINQ expressions only |
GetProperty(ISqlObject, String)
Property get handler used in XData mapping
Declaration
public static object GetProperty(this ISqlObject obj, string property)
Parameters
Type | Name | Description |
---|---|---|
ISqlObject | obj | Object |
String | property | Property name |
Returns
Type | Description |
---|---|
Object | Property |
GetVariable<TResult>(IQueryStructureAdapter, String)
Declaration
public static TResult GetVariable<TResult>(this IQueryStructureAdapter adapter, string variableName)
Parameters
Type | Name | Description |
---|---|---|
IQueryStructureAdapter | adapter | |
String | variableName |
Returns
Type | Description |
---|---|
TResult |
Type Parameters
Name | Description |
---|---|
TResult |
HasFlag<T>(IQueryStructureAdapter, Expression<Func<IQueryStructureAdapter, T>>, Expression<Func<IQueryStructureAdapter, T>>, Expression<Func<IQueryStructureAdapter, T>>, Expression<Func<IQueryStructureAdapter, T>>)
Bit mask has flag
Declaration
public static T HasFlag<T>(this IQueryStructureAdapter adapter, Expression<Func<IQueryStructureAdapter, T>> expression, Expression<Func<IQueryStructureAdapter, T>> flagValue, Expression<Func<IQueryStructureAdapter, T>> trueValue, Expression<Func<IQueryStructureAdapter, T>> falseValue)
Parameters
Type | Name | Description |
---|---|---|
IQueryStructureAdapter | adapter | Source query structure adapter |
Expression<Func<IQueryStructureAdapter, T>> | expression | Expression to test |
Expression<Func<IQueryStructureAdapter, T>> | flagValue | Flag value |
Expression<Func<IQueryStructureAdapter, T>> | trueValue | Result if flag exists |
Expression<Func<IQueryStructureAdapter, T>> | falseValue | Result if flag not exists |
Returns
Type | Description |
---|---|
T | Bit mask has flag than trueValue else falseValue |
Type Parameters
Name | Description |
---|---|
T |
Exceptions
Type | Condition |
---|---|
XDataRuntimeException | Function accessible in XData LINQ expressions only |
SetCombination<T>(T, String)
Set combination name to filter description
Declaration
public static T SetCombination<T>(this T desc, string combinationName)
where T : IFilterDescription
Parameters
Type | Name | Description |
---|---|---|
T | desc | Filter description |
String | combinationName | Filter combination name |
Returns
Type | Description |
---|---|
T | Filter description |
Type Parameters
Name | Description |
---|---|
T | Filter description type |
Exceptions
Type | Condition |
---|---|
XDataRuntimeException | desc argument can not be null |
SetExpression<TTag, TResult>(TTag, Expression<Func<IQueryStructureAdapter, TResult>>)
Set expression to tag
Declaration
public static TaggedExpression<TTag, TResult> SetExpression<TTag, TResult>(this TTag key, Expression<Func<IQueryStructureAdapter, TResult>> expression)
Parameters
Type | Name | Description |
---|---|---|
TTag | key | Tag value |
Expression<Func<IQueryStructureAdapter, TResult>> | expression | Expression |
Returns
Type | Description |
---|---|
TaggedExpression<TTag, TResult> | Tagged expression |
Type Parameters
Name | Description |
---|---|
TTag | Tag type |
TResult | Expression result |
SetOperation<T>(T, FilterOperation)
Set filter or link operation
Declaration
public static T SetOperation<T>(this T desc, FilterOperation operation)
where T : IFilterDescription
Parameters
Type | Name | Description |
---|---|---|
T | desc | Filter description |
FilterOperation | operation | Filter operation |
Returns
Type | Description |
---|---|
T | Filter description |
Type Parameters
Name | Description |
---|---|
T | Filter description type |
Exceptions
Type | Condition |
---|---|
XDataRuntimeException | desc argument can not be null or empty |
See Also
| Improve this Doc View SourceSqlExpr<TResult>(IQueryStructureAdapter, String, Expression<Func<IQueryStructureAdapter, Object>>[])
Plain SQL expression with XData LINQ expression placeholders
Declaration
public static TResult SqlExpr<TResult>(this IQueryStructureAdapter adapter, string format, params Expression<Func<IQueryStructureAdapter, object>>[] expressions)
Parameters
Type | Name | Description |
---|---|---|
IQueryStructureAdapter | adapter | Source query structure adapter |
String | format | SQL expression body in Format(String, Object[]) style |
Expression<Func<IQueryStructureAdapter, Object>>[] | expressions | XData LINQ parameter expressions |
Returns
Type | Description |
---|---|
TResult | SQL expression result |
Type Parameters
Name | Description |
---|---|
TResult |
Remarks
WARNING! Plain SQL expressions can use specific SQL dialect features!
Data mapping may be not compatible with other database engines!
Exceptions
Type | Condition |
---|---|
XDataRuntimeException | Function accessible in XData LINQ expressions only |
SqlFn<TResult>(IQueryStructureAdapter, String, Expression<Func<IQueryStructureAdapter, Object>>[])
SQL function call
Declaration
public static TResult SqlFn<TResult>(this IQueryStructureAdapter adapter, string name, params Expression<Func<IQueryStructureAdapter, object>>[] parameters)
Parameters
Type | Name | Description |
---|---|---|
IQueryStructureAdapter | adapter | Source query structure adapter |
String | name | SQL function full qualified name |
Expression<Func<IQueryStructureAdapter, Object>>[] | parameters | Function parameters descriptions |
Returns
Type | Description |
---|---|
TResult | Function call result |
Type Parameters
Name | Description |
---|---|
TResult |
Exceptions
Type | Condition |
---|---|
XDataRuntimeException | Function accessible in XData LINQ expressions only |
SqlParam<TResult>(IQueryStructureAdapter, String, DbType, Expression<Func<IProcedureParameterAdapter, IProcedureParameterFlag>>[])
SQL parameter definition
Declaration
public static TResult SqlParam<TResult>(this IQueryStructureAdapter adapter, string binding, DbType type, params Expression<Func<IProcedureParameterAdapter, IProcedureParameterFlag>>[] attributes)
Parameters
Type | Name | Description |
---|---|---|
IQueryStructureAdapter | adapter | Query structure adapter |
String | binding | Parameter data binding name |
DbType | type | Parameter database type |
Expression<Func<IProcedureParameterAdapter, IProcedureParameterFlag>>[] | attributes | Parameter mapping attributes |
Returns
Type | Description |
---|---|
TResult | Parameter |
Type Parameters
Name | Description |
---|---|
TResult | Parameter mapped type |
Exceptions
Type | Condition |
---|---|
XDataRuntimeException | Function accessible in XData LINQ expressions only |
ToDataSet<T>(IEnumerable<T>, String, ISqlBuilder)
Composes data source text from sequence
Declaration
public static string ToDataSet<T>(this IEnumerable<T> source, string prefix, ISqlBuilder builder)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | source | Source sequence |
String | prefix | Source column prefix |
ISqlBuilder | builder | SQL dialect adapter |
Returns
Type | Description |
---|---|
String | Data source text |
Type Parameters
Name | Description |
---|---|
T | Source object type |
Remarks
Used to compose synthetic data source from object sequence
var ds = Enumerable.Range(1,3).ToDataSet("val", XDataManager.GetContext().DialectAdapter);
// for MSSQL dialect ds will contains "(select 1 as val union select 2 as val union select 3 as val)"
// for Oracle dialect ds will contains "(select 1 as val from dual union select 2 as val from dual union select 3 as val from dual)"
// Enumeration types can be used as
var ds = Enum.GetValues(typeof(SomeEnumType)).Cast<int>().ToDataSet("val", XDataManager.GetContext().DialectAdapter);
// Object types properties are represented as fields
var test = new []{new {Id=1, Name="Test"}, new {Id=2, Name="Another"}};
var ds = test.ToDataSet("X", XDataManager.GetContext().DialectAdapter);
// for MSSQL dialect ds will contains "(select 1 as X_Id, 'Test' as X_Name union select 2 as X_Id, 'Another' as X_Name)"