///<summary> ///</summary> ///<param name="crossRefTable"></param> ///<param name="inExpList"></param> ///<param name="columnNames"></param> ///<param name="context"></param> public FunctionTable(Table crossRefTable, Expression[] inExpList, string[] columnNames, IQueryContext context) : base(context.Connection.Database) { // Make sure we are synchronized over the class. lock (typeof(FunctionTable)) { uniqueId = UniqueKeySeq; ++UniqueKeySeq; } uniqueId = (uniqueId & 0x0FFFFFFF) | 0x010000000; this.context = context; this.crossRefTable = crossRefTable; crResolver = crossRefTable.GetVariableResolver(); crResolver.SetId = 0; // Create a DataTableInfo object for this function table. funTableInfo = new DataTableInfo(FunctionTableName); expList = new Expression[inExpList.Length]; expInfo = new byte[inExpList.Length]; // Create a new DataColumnInfo for each expression, and work out if the // expression is simple or not. for (int i = 0; i < inExpList.Length; ++i) { Expression expr = inExpList[i]; // Examine the expression and determine if it is simple or not if (expr.IsConstant() && !expr.HasAggregateFunction(context)) { // If expression is a constant, solve it DataObject result = expr.Evaluate(null, null, context); expr = Expression.Constant(result); expList[i] = expr; expInfo[i] = 1; } else { // Otherwise must be dynamic expList[i] = expr; expInfo[i] = 0; } // Make the column info funTableInfo.AddColumn(columnNames[i], expr.ReturnType(crResolver, context)); } // Make sure the table info isn't changed from this point on. funTableInfo.IsReadOnly = true; // Function tables are the size of the referring table. row_count = crossRefTable.RowCount; // Set schemes to 'blind search'. BlankSelectableSchemes(1); }
///<summary> ///</summary> ///<param name="crossRefTable"></param> ///<param name="inExpList"></param> ///<param name="columnNames"></param> ///<param name="context"></param> public FunctionTable(Table crossRefTable, Expression[] inExpList, string[] columnNames, IQueryContext context) : base(context.Connection.Database) { // Make sure we are synchronized over the class. lock (typeof (FunctionTable)) { uniqueId = UniqueKeySeq; ++UniqueKeySeq; } uniqueId = (uniqueId & 0x0FFFFFFF) | 0x010000000; this.context = context; this.crossRefTable = crossRefTable; crResolver = crossRefTable.GetVariableResolver(); crResolver.SetId = 0; // Create a DataTableInfo object for this function table. funTableInfo = new DataTableInfo(FunctionTableName); expList = new Expression[inExpList.Length]; expInfo = new byte[inExpList.Length]; // Create a new DataColumnInfo for each expression, and work out if the // expression is simple or not. for (int i = 0; i < inExpList.Length; ++i) { Expression expr = inExpList[i]; // Examine the expression and determine if it is simple or not if (expr.IsConstant() && !expr.HasAggregateFunction(context)) { // If expression is a constant, solve it DataObject result = expr.Evaluate(null, null, context); expr = Expression.Constant(result); expList[i] = expr; expInfo[i] = 1; } else { // Otherwise must be dynamic expList[i] = expr; expInfo[i] = 0; } // Make the column info funTableInfo.AddColumn(columnNames[i], expr.ReturnType(crResolver, context)); } // Make sure the table info isn't changed from this point on. funTableInfo.IsReadOnly = true; // Function tables are the size of the referring table. row_count = crossRefTable.RowCount; // Set schemes to 'blind search'. BlankSelectableSchemes(1); }