/// <summary> /// Generates a collection of sql statements to insert the business /// object's properties into the database /// </summary> /// <returns>Returns a sql statement collection</returns> public IEnumerable<ISqlStatement> Generate() { _statements = new List<ISqlStatement>(); _currentClassDef = _bo.ClassDef; IBOPropCol propsToInclude; string tableName; propsToInclude = GetPropsToInclude(_currentClassDef); tableName = StatementGeneratorUtils.GetTableName(_bo); GenerateSingleInsertStatement(propsToInclude, tableName); if (_bo.ClassDef.IsUsingClassTableInheritance()) { _currentClassDef = (ClassDef) _bo.ClassDef.SuperClassClassDef; while (_currentClassDef.IsUsingClassTableInheritance()) { propsToInclude = GetPropsToInclude(_currentClassDef); tableName = _currentClassDef.TableName; GenerateSingleInsertStatement(propsToInclude, tableName); _currentClassDef = (ClassDef) _currentClassDef.SuperClassClassDef; } propsToInclude = GetPropsToInclude(_currentClassDef); tableName = _currentClassDef.InheritedTableName; GenerateSingleInsertStatement(propsToInclude, tableName); } return _statements; }
/// <summary> /// Generates a collection of sql statements to insert the business /// object's properties into the database /// </summary> /// <returns>Returns a sql statement collection</returns> public IEnumerable <ISqlStatement> Generate() { _statements = new List <ISqlStatement>(); _currentClassDef = _bo.ClassDef; IBOPropCol propsToInclude; string tableName; propsToInclude = GetPropsToInclude(_currentClassDef); tableName = StatementGeneratorUtils.GetTableName(_bo); GenerateSingleInsertStatement(propsToInclude, tableName); if (_bo.ClassDef.IsUsingClassTableInheritance()) { _currentClassDef = (ClassDef)_bo.ClassDef.SuperClassClassDef; while (_currentClassDef.IsUsingClassTableInheritance()) { propsToInclude = GetPropsToInclude(_currentClassDef); tableName = _currentClassDef.TableName; GenerateSingleInsertStatement(propsToInclude, tableName); _currentClassDef = (ClassDef)_currentClassDef.SuperClassClassDef; } propsToInclude = GetPropsToInclude(_currentClassDef); tableName = _currentClassDef.InheritedTableName; GenerateSingleInsertStatement(propsToInclude, tableName); } return(_statements); }
/// <summary> /// Generates a collection of sql statements to update the business /// object's properties in the database /// </summary> /// <returns>Returns a sql statement collection</returns> public IEnumerable <ISqlStatement> Generate() { _statements = new List <ISqlStatement>(); IBOPropCol propsToInclude; string tableName; ClassDef currentClassDef = _bo.ClassDef; while (currentClassDef.IsUsingClassTableInheritance()) { var superClassClassDef = (ClassDef)currentClassDef.SuperClassClassDef; propsToInclude = GetPropsToInclude(superClassClassDef); if (propsToInclude.Count > 0) { tableName = superClassClassDef.InheritedTableName; GenerateSingleUpdateStatement(tableName, propsToInclude, true, currentClassDef); } currentClassDef = superClassClassDef; } propsToInclude = GetPropsToInclude(_bo.ClassDef); tableName = StatementGeneratorUtils.GetTableName(_bo); GenerateSingleUpdateStatement(tableName, propsToInclude, false, _bo.ClassDef); return(_statements); }