public static DatabaseTreeViewModel ToViewModel(this List <Database> entities, DBConnect dbConnect, List <Product> produects) { DatabaseTreeViewModel databaseTree = new DatabaseTreeViewModel(); if (entities != null) { string productName = produects.FirstOrDefault(d => d.Name.Equals("ProductName"))?.Value.ToString(); string productVersion = produects.FirstOrDefault(d => d.Name.Equals("ProductVersion"))?.Value.ToString(); databaseTree.Name = $"{dbConnect.Address}({productName} {productVersion} - {dbConnect.Userename})"; databaseTree.NodeType = DBTreeNodeType.Server; databaseTree.Children = new List <DatabaseTreeViewModel>(); DatabaseTreeViewModel dbTree = new DatabaseTreeViewModel(); dbTree.Name = "数据库"; dbTree.NodeType = DBTreeNodeType.Docmenu; dbTree.Children = new List <DatabaseTreeViewModel>(); foreach (var db in entities) { DatabaseTreeViewModel t = new DatabaseTreeViewModel(); t.Name = db.Name; t.NodeType = DBTreeNodeType.Docmenu; t.Children = new List <DatabaseTreeViewModel>(); dbTree.Children.Add(t); } databaseTree.Children.Add(dbTree); } return(databaseTree); }
public QueryBuilderController( QueryBuilderService queryBuilderService, QueryBuilderWindowViewModel queryBuilderWindowViewModel, DatabaseTreeViewModel databaseTreeViewModel, QueryGridViewModel queryBuilderViewModel ) { queryBuilderService_ = queryBuilderService; queryBuilderWindowViewModel_ = queryBuilderWindowViewModel; databaseTreeViewModel_ = databaseTreeViewModel; queryBuilderViewModel_ = queryBuilderViewModel; queryBuilderService.DataBaseTreeView = databaseTreeViewModel.View; queryBuilderService.QueryGridView = queryBuilderViewModel.View; }