Пример #1
0
        private void WriteClassMembers(string className)
        {
            if (_codeWriterSettings.CodeTarget == CodeTarget.PocoRiaServices)
            {
                RiaServicesWriter.WritePrivateConstructor(className, _cb);
            }
            else
            {
                InitializeCollectionsInConstructor(className);
            }

            if (_inheritanceTable == null)
            {
                WritePrimaryKey(className);
            }

            foreach (var column in _table.Columns)
            {
                if (column.IsPrimaryKey)
                {
                    continue;
                }
                if (column.IsForeignKey)
                {
                    continue;
                }
                WriteColumn(column);
            }

            foreach (var foreignKey in _table.ForeignKeys)
            {
                WriteForeignKey(foreignKey);
            }

            WriteForeignKeyCollections();

            if (!_table.HasCompositeKey &&
                _codeWriterSettings.CodeTarget != CodeTarget.PocoRiaServices &&
                _inheritanceTable == null)
            {
                var overrider = new OverrideWriter(_cb, _table, _codeWriterSettings.Namer);
                overrider.AddOverrides();
            }
        }
Пример #2
0
        private void WriteCompositeKeyClass(string className)
        {
            //CodeFirst can cope with multi-keys
            if (IsEntityFramework())
            {
                return;
            }

            using (_cb.BeginNest("public class " + className + "Key", "Class representing " + _table.Name + " composite key"))
            {
                foreach (var column in _table.Columns.Where(x => x.IsPrimaryKey))
                {
                    WriteColumn(column);
                }

                var overrider = new OverrideWriter(_cb, _table, _codeWriterSettings.Namer);
                overrider.NetName = className + "Key";
                overrider.AddOverrides();
            }
        }