private void InitFilters(IEnumerable <IColumnDescriptor> filterList) { Dictionary <ITableDescriptor, IReadOnlyCollection <IColumnDescriptor> > FilterTable = new Dictionary <ITableDescriptor, IReadOnlyCollection <IColumnDescriptor> >(); foreach (IColumnDescriptor Column in filterList) { ITableDescriptor Table = Column.Table; if (!FilterTable.ContainsKey(Table)) { FilterTable.Add(Table, new List <IColumnDescriptor>()); } IList <IColumnDescriptor> ColumnFilter = (IList <IColumnDescriptor>)FilterTable[Table]; ColumnFilter.Add(Column); } Filters = FilterTable; }
public Type getColumnType(string pTableName, string pColName, Type pDef) { if (ToolColumn.isColumnFullName(pColName)) { pTableName = ToolColumn.extractTableName(pColName); pColName = ToolColumn.extractColumnName(pColName); } ITableDescriptor tds = getTable(pTableName); if (tds != null) { ColumnDescriptor cds = tds.getColumn(pColName); if (cds != null) { return(cds.type); } } return(pDef); }
protected virtual string GetTableReference() { IReadOnlyDictionary <IColumnDescriptor, IColumnDescriptor> Join = Context.Join.Columns; string JoinResult = ""; foreach (KeyValuePair <IColumnDescriptor, IColumnDescriptor> Entry in Join) { IColumnDescriptor LeftColumn = Entry.Key; ITableDescriptor LeftTable = LeftColumn.Table; string LeftTableName = LeftTable.Name; string LeftColumnName = LeftColumn.Name; IColumnDescriptor RightColumn = Entry.Value; ITableDescriptor RightTable = RightColumn.Table; string RightTableName = RightTable.Name; string RightColumnName = RightColumn.Name; if (JoinResult.Length == 0) { JoinResult = RightTableName; } JoinResult += " LEFT JOIN " + LeftTableName + " ON " + LeftTableName + "." + LeftColumnName + "=" + RightTableName + "." + RightColumnName; } if (JoinResult.Length == 0) { IReadOnlyDictionary <ITableDescriptor, IReadOnlyCollection <IColumnDescriptor> > Filters = Context.Filters; foreach (KeyValuePair <ITableDescriptor, IReadOnlyCollection <IColumnDescriptor> > Entry in Filters) { ITableDescriptor Table = Entry.Key; string TableName = Table.Name; JoinResult = TableName; break; } } return(JoinResult); }
private void initCommands(DbDataAdapter pAdp, DataTable pData, ITableDescriptor pTabDesc) { if (CurrentVersion.ENV.isDebugMode()) { ToolMobile.setRuntimeMsg("ImplAdapterTableExt:initCommands:beg"); } DataColumn colV_ = pData.Columns[TableDUMMY.RECVERS]; foreach (DataRow row in pData.Rows) { switch (row.RowState) { case DataRowState.Added: if (pAdp.InsertCommand == null) { initCommandInsert(pAdp, pTabDesc); } break; case DataRowState.Deleted: if (pAdp.DeleteCommand == null) { initCommandDelete(pAdp, pTabDesc); } break; case DataRowState.Modified: if (colV_ != null) { short rv_ = Convert.ToInt16(ToolCell.isNull(row[colV_, DataRowVersion.Original], 0)); ++rv_; ToolCell.set(row, colV_, rv_); } if (pAdp.UpdateCommand == null) { initCommandUpdate(pAdp, pTabDesc); } break; } } }
public void MoveToTable(Authentication authentication, ITableDescriptor descriptor, string columnName, int row) { if (authentication == null) { throw new ArgumentNullException(nameof(authentication)); } if (descriptor == null) { throw new ArgumentNullException(nameof(descriptor)); } //if (descriptor.Target is ITable table) //{ // this.MoveToTable(authentication, table, columnName, row); //} //else //{ // throw new NotImplementedException(); //} }
public virtual string FinalizeOperation(MySqlCommand command, ISingleQueryResultInternal result) { try { using (MySqlDataReader Reader = command.EndExecuteReader(result.AsyncResult)) { ITableDescriptor Table = Context.Table; ISchemaDescriptor Schema = Table.Schema; IReadOnlyCollection <IColumnDescriptor> TableStructure = Schema.Tables[Table]; FillResult(Reader, TableStructure, out List <IResultRow> Rows); result.SetCompletedWithRows(Rows); return($"succeeded, {Rows.Count} row(s) returned"); } } catch { result.SetCompleted(false, ResultError.ErrorExceptionCompletingQuery); throw; } }
public override void SelectObject(object obj) { this.descriptor = obj as ITableDescriptor; if (this.descriptor != null) { var types = EnumerableUtility.Descendants <TreeViewItemViewModel, ITypeDescriptor>(this.Browser.Items, item => item.Items); var query = from column in this.descriptor.TableInfo.Columns join type in types on column.DataType equals(type.TypeInfo.CategoryPath + type.TypeInfo.Name) select type; var descriptors = query.Distinct().ToArray(); var viewModelList = new List <TypeListBoxItemViewModel>(); foreach (var item in descriptors) { var type = item.Target; if (type.ExtendedProperties.ContainsKey(this) == true) { var descriptor = type.ExtendedProperties[this] as TypeDescriptor; viewModelList.Add(descriptor.Host as TypeListBoxItemViewModel); } else { var viewModel = new TypeListBoxItemViewModel(this.authenticator, item, this); this.compositionService.SatisfyImportsOnce(viewModel); viewModelList.Add(viewModel); } } this.Types = viewModelList.ToArray(); } else { this.Types = new TypeListBoxItemViewModel[] { }; } this.NotifyOfPropertyChange(nameof(this.IsVisible)); this.NotifyOfPropertyChange(nameof(this.SelectedObject)); }
public override void SelectObject(object obj) { if (this.descriptor != null) { if (this.descriptor is INotifyPropertyChanged) { (this.descriptor as INotifyPropertyChanged).PropertyChanged -= Table_PropertyChanged; } } this.descriptor = obj as ITableDescriptor; if (this.descriptor != null) { if (this.descriptor is INotifyPropertyChanged) { (this.descriptor as INotifyPropertyChanged).PropertyChanged += Table_PropertyChanged; } var browser = this.browser.Value; var types = EnumerableUtility.Descendants <TreeViewItemViewModel, TypeTreeViewItemViewModel>(browser.Items, item => item.Items); var query = from item in this.descriptor.TableInfo.Columns join type in types on item.DataType equals(type.TypeInfo.CategoryPath + type.TypeInfo.Name) select type; var typeItems = query.Distinct() .Select(item => new TypeListBoxItemViewModel(item)) .ToArray(); foreach (var item in typeItems) { compositionService.SatisfyImportsOnce(item); } this.Types = typeItems; } this.NotifyOfPropertyChange(nameof(this.IsVisible)); this.NotifyOfPropertyChange(nameof(this.SelectedObject)); }
protected virtual IColumnValuePair GetLastCreatedKeyId(MySqlCommand command, IInsertResultInternal result) { ITableDescriptor Table = Context.Table; IReadOnlyCollection <IColumnValueCollectionPair> ColumnInitialValues = Context.EntryList; IColumnDescriptor PrimaryKeyColumn = Table.PrimaryKey; if (PrimaryKeyColumn is IColumnDescriptorInt AsIntColumn) { return(new ColumnValuePair <int>(AsIntColumn, (int)command.LastInsertedId)); } foreach (IColumnValueCollectionPair Entry in ColumnInitialValues) { if (Entry.Column == PrimaryKeyColumn) { return(Entry.LastEntry); } } Debug.Assert(false); return(null); }
protected virtual bool GetConstraintString(out string constraintString) { IReadOnlyDictionary <ITableDescriptor, IColumnValueCollectionPair> Constraints = Context.Constraints; if (Constraints.Count > 0) { constraintString = ""; foreach (KeyValuePair <ITableDescriptor, IColumnValueCollectionPair> Entry in Constraints) { ITableDescriptor Table = Entry.Key; IColumnDescriptor Column = Entry.Value.Column; IEnumerable ValueList = Entry.Value.ValueCollection; string TableName = Table.Name; string ColumnName = Column.Name; foreach (object Value in ValueList) { if (constraintString.Length > 0) { constraintString += " OR "; } IColumnType ColumnType = Column.Type; string FormattedValue = ColumnType.ToSqlFormat(Value); constraintString += "(" + TableName + "." + ColumnName + "=" + FormattedValue + ")"; } } return(true); } else { constraintString = null; return(false); } }
public override void SelectObject(object obj) { this.descriptor = obj as ITableDescriptor; if (this.descriptor != null) { var items = EnumerableUtility.Descendants <TreeViewItemViewModel, ITableDescriptor>(this.Browser.Items, item => item.Items) .Where(item => item.TableInfo.TemplatedParent == this.descriptor.Name) .ToArray(); var viewModelList = new List <TableListBoxItemViewModel>(); foreach (var item in items) { var table = item.Target; if (table.ExtendedProperties.ContainsKey(this) == true) { var descriptor = table.ExtendedProperties[this] as TableDescriptor; viewModelList.Add(descriptor.Host as TableListBoxItemViewModel); } else { var viewModel = new TableListBoxItemViewModel(this.authenticator, item, this); this.compositionService.SatisfyImportsOnce(viewModel); viewModelList.Add(viewModel); } } this.Tables = viewModelList.ToArray(); } else { this.Tables = new TableListBoxItemViewModel[] { }; } this.NotifyOfPropertyChange(nameof(this.IsVisible)); this.NotifyOfPropertyChange(nameof(this.SelectedObject)); }
/// <summary> /// Initializes a new instance of the <see cref="MultiRowConstrainableContext"/> class. /// This request has a constraint: one column must match one value among many. /// </summary> /// <parameters> /// <param name="table">The table addressed by the request.</param> /// <param name="constraint">The column and values it must take to match.</param> /// </parameters> /// <exception cref="ArgumentNullException"> /// <paramref name="table"/> is null. /// </exception> /// <exception cref="ArgumentNullException"> /// <paramref name="constraint"/> is null. /// </exception> public MultiRowConstrainableContext(ITableDescriptor table, IColumnValueCollectionPair constraint) : base(table) { SingleConstraintEntry = constraint ?? throw new ArgumentNullException(nameof(constraint)); MultipleConstraintList = null; }
public DataModelMemberDescriptor(LinqToDB.Mapping.ColumnDescriptor columnDescriptor, ITableDescriptor table) { Name = columnDescriptor.MemberName; Table = table; PropertyInfoEx = new PropertyInfoEx(columnDescriptor.MemberInfo as PropertyInfo); //var propertyInfo = entity.EntityType.GetProperty(property.Name); //PropertyInfoEx = new PropertyInfoEx(propertyInfo); //if (property.IsCollectionType) // MemberType = EntityMemberType.CollectionProperty; ////else if (property.isna) Navigation??? //else // MemberType = EntityMemberType.ValueProperty; }
public static async Task <bool> EditContentAsync(Authentication authentication, ITableDescriptor descriptor) { if (descriptor.Target is ITable table && table.GetService(typeof(TableDocumentServiceViewModel)) is TableDocumentServiceViewModel documentService) { var document = documentService.Find(descriptor) ?? documentService.OpenTable(authentication, descriptor); document.SelectedTable = documentService.FindItem(descriptor); documentService.SelectedDocument = document; return(await Task.Run(() => true)); }
/// <summary> /// Initializes a new instance of the <see cref="MultiRowConstrainableContext"/> class. /// This request has no constraints. /// </summary> /// <parameters> /// <param name="table">The table addressed by the request.</param> /// </parameters> /// <exception cref="ArgumentNullException"> /// <paramref name="table"/> is null. /// </exception> public MultiRowConstrainableContext(ITableDescriptor table) : base(table) { SingleConstraintEntry = null; MultipleConstraintList = null; }
ITableDocument ITableDocumentService.ViewTable(Authentication authentication, ITableDescriptor descriptor) { return(this.ViewTable(authentication, descriptor)); }
protected virtual string GetTableName() { ITableDescriptor Table = Context.Table; return(Table.Name); }
/// <summary> /// Initializes a new instance of the <see cref="CommandBuilderBase"/> class. /// </summary> /// <param name="connector">A database connector.</param> /// <param name="descriptor">A table type descriptor.</param> protected CommandBuilderBase(IDatabaseConnector connector, ITableDescriptor descriptor) { this.Connector = connector; this.Descriptor = descriptor; this.FormatProvider = connector.GetCommandFormatProvider(); }
public BookmarkTableTreeViewItemViewModel(Authentication authentication, ITableDescriptor descriptor, object owner) : base(authentication, new TableDescriptor(authentication, descriptor, true), owner) { this.Descriptor.PropertyChanged += Descriptor_PropertyChanged; }
public static Task <DeleteTableViewModel> CreateInstanceAsync(Authentication authentication, ITableDescriptor descriptor) { if (authentication == null) { throw new ArgumentNullException(nameof(authentication)); } if (descriptor == null) { throw new ArgumentNullException(nameof(descriptor)); } if (descriptor.Target is ITable table) { return(table.Dispatcher.InvokeAsync(() => { return new DeleteTableViewModel(authentication, table); })); } else { throw new ArgumentException("Invalid Target of Descriptor", nameof(descriptor)); } }
public TableListItemBase(Authentication authentication, ITableDescriptor descriptor, object owner) : base(authentication, new TableDescriptor(authentication, descriptor, true, owner), owner) { }
public static async Task <FindResultInfo[]> FindAsync(Authentication authentication, ITableDescriptor descriptor, string text, FindOptions options) { if (descriptor.Target is ITable table) { return(await table.FindAsync(authentication, text, options)); } else { throw new NotImplementedException(); } }
void addTableDesc(string pTabNameShort, ITableDescriptor pDesc) { dic.Add(pTabNameShort, pDesc); }
/// <summary> /// Initializes a new instance of the <see cref="InsertCommandBuilderBase"/> class. /// </summary> /// <param name="connector">A database connector.</param> /// <param name="descriptor">A table type descriptor.</param> protected InsertCommandBuilderBase(IDatabaseConnector connector, ITableDescriptor descriptor) : base(connector, descriptor) { this.Initialize(); }
/// <summary> /// Initializes a new instance of the <see cref="UpdateContext"/> class. /// This request has a constraint: several columns must match a given value. /// If <paramref name="constraintList"/> is empty, no constraint will be applied to the request. /// If <paramref name="entryList"/> is empty, nothing is updated and the request returns success immediately. /// </summary> /// <parameters> /// <param name="table">The table addressed by the request.</param> /// <param name="constraintList">The columns and value they must take to match.</param> /// <param name="entryList">The colums and new values to update.</param> /// </parameters> /// <exception cref="ArgumentNullException"> /// <paramref name="table"/> is null. /// </exception> /// <exception cref="ArgumentNullException"> /// <paramref name="constraintList"/> is null. /// </exception> /// <exception cref="ArgumentNullException"> /// <paramref name="entryList"/> is null. /// </exception> public UpdateContext(ITableDescriptor table, IEnumerable <IColumnValuePair> constraintList, IEnumerable <IColumnValuePair> entryList) : base(table, constraintList) { InitEntryList(entryList); }
public static Task <ViewTemplateViewModel> CreateInstanceAsync(Authentication authentication, ITableDescriptor descriptor) { if (authentication == null) { throw new ArgumentNullException(nameof(authentication)); } if (descriptor == null) { throw new ArgumentNullException(nameof(descriptor)); } if (descriptor.Target is ITable table) { return(table.Dispatcher.InvokeAsync(() => { var dataSet = table.GetDataSet(authentication, -1); var dataTable = dataSet.Tables[table.Name]; var template = new CremaTemplate(dataTable); return new ViewTemplateViewModel(authentication, template); })); } else { throw new ArgumentException("Invalid Target of Descriptor", nameof(descriptor)); } }
/// <summary> /// Initializes a new instance of the <see cref="CqlSelectOneCommandBuilder"/> class. /// </summary> /// <param name="connector">A database connector.</param> /// <param name="descriptor">A table type descriptor.</param> public CqlSelectOneCommandBuilder(IDatabaseConnector connector, ITableDescriptor descriptor) : base(connector, descriptor) { }
public override void SelectObject(object obj) { this.Detach(); this.descriptor = obj as ITableDescriptor; this.Attach(); }
/// <summary> /// Initializes a new instance of the <see cref="SqlDeleteCommandBuilder"/> class. /// </summary> /// <param name="connector">A database connector.</param> /// <param name="descriptor">A table type descriptor.</param> public SqlDeleteCommandBuilder(IDatabaseConnector connector, ITableDescriptor descriptor) : base(connector, descriptor) { this.Initialize(); }
public static async Task <CremaDataSet> GetDataAsync(Authentication authentication, ITableDescriptor descriptor, string revision) { if (descriptor.Target is ITable table) { return(await table.GetDataSetAsync(authentication, revision)); } else { throw new NotImplementedException(); } }