Exemplo n.º 1
0
 public IEnumerable<IPropertySymbol> GetRefTables(IPropertySymbol dbTable, IPropertySymbol foreignKey)
 {
     var pkType = foreignKey?.Type;
     if (pkType == null)
         return ImmutableArray<IPropertySymbol>.Empty;
     else
         return DbType.GetTypeMembers<IPropertySymbol>(IsDbTable).Where(x => pkType.Equals(x.GetModelType().GetPkType(Compilation)));
 }
Exemplo n.º 2
0
        public IEnumerable GetModelTypeSelection()
        {
            var dbTables = DbType.GetTypeMembers<IPropertySymbol>(IsDbTable);
            var existingDbTableModels = new HashSet<INamedTypeSymbol>();
            foreach (var dbTable in dbTables)
            {
                var modelType = dbTable.GetModelType();
                if (modelType != null)
                    existingDbTableModels.Add(modelType);
            }

            return ModelTypeVisitor.Walk(Compilation, existingDbTableModels).Select(x => new { Value = x, Display = x.Name }).OrderBy(x => x.Display).ToArray();
        }
Exemplo n.º 3
0
        private void InitRelationshipItems(DataRow root)
        {
            DataRow folderRow = null;

            foreach (var node in DbType.GetTypeMembers <IMethodSymbol>(IsForeignKeyImplementation).Select(CreateNode))
            {
                if (folderRow == null)
                {
                    folderRow = AddRow(root, new FolderNode(this, UserMessages.FolderName_Relationship));
                }
                AddRow(folderRow, node);
            }

            bool IsForeignKeyImplementation(IMethodSymbol methodSymbol)
            {
                return(methodSymbol.HasAttribute(Compilation.GetKnownType(KnownTypes._RelationshipAttribute)));
            }

            Node CreateNode(IMethodSymbol methodSymbol)
            {
                return(new RelationshipImplementationNode(this, methodSymbol));
            }
        }