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

            if (_table.HasCompositeKey)
            {
                if (!IsEntityFramework())
                {
                    _cb.AppendAutomaticProperty(className + "Key", "Key");
                }
                else
                {
                    //code first composite key
                    foreach (var column in _table.Columns.Where(c => c.IsPrimaryKey))
                    {
                        WriteColumn(column);
                    }
                }
            }

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

            // KL: Writing out all foreign keys on their own. Needed for composite foreign keys.
            foreach (var fKey in _table.ForeignKeys)
            {
                WriteForeignKey(fKey);
            }

            WriteForeignKeyCollections();

            if (!_table.HasCompositeKey && _codeWriterSettings.CodeTarget != CodeTarget.PocoRiaServices)
            {
                var overrider = new OverrideWriter(_cb, _table);
                overrider.AddOverrides();
            }
        }
Example #2
0
        private void WriteClassMembers(string className)
        {
            if (_codeWriterSettings.CodeTarget == CodeTarget.PocoRiaServices)
            {
                RiaServicesWriter.WritePrivateConstructor(className, _cb);
            }
            else
            {
                InitializeCollectionsInConstructor(className);
            }

            _codeWriterSettings.CodeInserter.WriteClassMembers(_table, _cb);

            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();
            }
        }
Example #3
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();
            }
        }
Example #4
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();
            }
        }
Example #5
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();
            }
        }