public void GenerateContent(StringBuilder sb) { if (_model.Database.AllowZeroTouch) { return; } if (_currentTable.IsTypeTable) { return; } if (_currentTable.Immutable) { return; } if (_currentTable.AssociativeTable) { return; } try { sb.AppendLine("if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[" + StoredProcedureName + "]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)"); sb.AppendLine(" drop procedure [dbo].[" + StoredProcedureName + "]"); sb.AppendLine("GO"); sb.AppendLine(); sb.AppendLine(); sb.AppendLine("SET QUOTED_IDENTIFIER ON "); sb.AppendLine("GO"); sb.AppendLine("SET ANSI_NULLS ON "); sb.AppendLine("GO"); sb.AppendLine(); sb.AppendLine("CREATE PROCEDURE [dbo].[" + StoredProcedureName + "]"); sb.AppendLine("("); sb.AppendLine(this.BuildParameterList()); sb.AppendLine(")"); sb.AppendLine("AS"); sb.AppendLine(); sb.Append(SQLGeneratedBodyHelper.SQLUpdateBusinessObjectBody(_currentTable, _model)); sb.AppendLine("GO"); sb.AppendLine("SET QUOTED_IDENTIFIER OFF"); sb.AppendLine("GO"); sb.AppendLine("SET ANSI_NULLS ON"); sb.AppendLine("GO"); sb.AppendLine(); if (_model.Database.GrantExecUser != string.Empty) { sb.AppendFormat("GRANT EXECUTE ON [dbo].[{0}] TO [{1}]", StoredProcedureName, _model.Database.GrantExecUser); sb.AppendLine(); sb.AppendLine("GO"); sb.AppendLine(); } } catch (Exception ex) { throw; } }
public void AppendFullTemplate() { try { sb.Append(SQLGeneratedBodyHelper.SQLDeleteBusinessObjectBody(_currentTable, _model)); } catch (Exception ex) { throw; } }
private void GenerateContent() { if (_model.Database.AllowZeroTouch) { return; } try { sb.AppendLine("--DO NOT MODIFY THIS FILE. IT IS ALWAYS OVERWRITTEN ON GENERATION."); sb.AppendLine("--Data Schema For Version " + _model.Version); ValidationHelper.AppendCopyrightInSQL(sb, _model); sb.AppendLine("if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[" + StoredProcedureName + "]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)"); sb.AppendLine(" drop procedure [dbo].[" + StoredProcedureName + "]"); sb.AppendLine("GO"); sb.AppendLine(); sb.AppendLine(); sb.AppendLine("SET QUOTED_IDENTIFIER ON "); sb.AppendLine("GO"); sb.AppendLine("SET ANSI_NULLS ON "); sb.AppendLine("GO"); sb.AppendLine(); sb.AppendLine("CREATE PROCEDURE [dbo].[" + StoredProcedureName + "]"); sb.AppendLine("("); sb.AppendLine(this.BuildParameterList()); sb.AppendLine(")"); sb.AppendLine("AS"); sb.AppendLine(); sb.Append(SQLGeneratedBodyHelper.SQLDeleteBusinessObjectBody(_currentTable, _model)); sb.AppendLine("GO"); sb.AppendLine("SET QUOTED_IDENTIFIER OFF"); sb.AppendLine("GO"); sb.AppendLine("SET ANSI_NULLS ON"); sb.AppendLine("GO"); sb.AppendLine(); if (_model.Database.GrantExecUser != string.Empty) { sb.AppendFormat("GRANT EXECUTE ON [dbo].[{0}] TO [{1}]", StoredProcedureName, _model.Database.GrantExecUser); sb.AppendLine(); sb.AppendLine("GO"); sb.AppendLine(); } } catch (Exception ex) { throw; } }
private void AppendFullTemplate(StringBuilder sb) { try { sb.AppendLine("if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[" + StoredProcedureName + "]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)"); sb.AppendLine(" drop procedure [dbo].[" + StoredProcedureName + "]"); sb.AppendLine("GO"); sb.AppendLine(); sb.AppendLine("SET QUOTED_IDENTIFIER ON "); sb.AppendLine("GO"); sb.AppendLine("SET ANSI_NULLS ON "); sb.AppendLine("GO"); sb.AppendLine(); sb.AppendLine("CREATE PROCEDURE [dbo].[" + StoredProcedureName + "]"); sb.AppendLine("("); sb.AppendLine(" @page int, -- page number selected by the user"); sb.AppendLine(" @pageSize int, -- number of items on the page"); sb.AppendLine(" @orderByColumn varchar(100), -- name of column to order things by"); sb.AppendLine(" @ascending bit, -- order column ascending or descending"); sb.AppendLine(" @filter varchar(100) = null, -- filter statement passed in to determine like criteria on order by column"); sb.AppendLine(" @count int out -- number of items in the collection"); sb.AppendLine(")"); sb.AppendLine("AS"); sb.AppendLine(); sb.AppendLine("SET NOCOUNT ON;"); sb.AppendLine(); sb.Append(SQLGeneratedBodyHelper.SQLPagedSelectBusinessObjectBody(_currentTable, _model)); sb.AppendLine(); sb.AppendLine("GO"); sb.AppendLine(); sb.AppendLine("SET QUOTED_IDENTIFIER OFF "); sb.AppendLine("GO"); sb.AppendLine("SET ANSI_NULLS ON "); sb.AppendLine("GO"); if (_model.Database.GrantExecUser != string.Empty) { sb.AppendFormat("GRANT EXECUTE ON [dbo].[{0}] TO [{1}]", StoredProcedureName, _model.Database.GrantExecUser).AppendLine(); sb.AppendLine("GO"); sb.AppendLine(); } } catch (Exception ex) { throw; } }
private void AppendFullTemplate(StringBuilder sb) { try { var moduleSuffix = string.Empty; if (!string.IsNullOrEmpty(_model.ModuleName)) { moduleSuffix = _model.ModuleName + "_"; } var storedProcedureName = _model.GetStoredProcedurePrefix() + "_" + _currentTable.PascalName + "_" + moduleSuffix + "Delete"; sb.AppendLine("if exists(select * from sys.objects where name = '" + storedProcedureName + "' and type = 'P' and type_desc = 'SQL_STORED_PROCEDURE')"); sb.AppendLine(" drop procedure [" + _currentTable.GetSQLSchema() + "].[" + storedProcedureName + "]"); sb.AppendLine("GO"); sb.AppendLine(); //Just drop the procedure if no CRUD SP if (!_model.Database.UseGeneratedCRUD) { return; } sb.AppendLine("CREATE PROCEDURE [" + _currentTable.GetSQLSchema() + "].[" + storedProcedureName + "]"); sb.AppendLine("("); sb.Append(BuildParameterList()); sb.AppendLine(")"); sb.AppendLine("AS"); sb.AppendLine("SET NOCOUNT OFF;"); sb.AppendLine(); sb.Append(SQLGeneratedBodyHelper.SQLDeleteBusinessObjectBody(_currentTable, _model)); sb.AppendLine("GO"); sb.AppendLine(); if (_model.Database.GrantExecUser != string.Empty) { sb.AppendFormat("GRANT EXECUTE ON [" + _currentTable.GetSQLSchema() + "].[{0}] TO [{1}]", storedProcedureName, _model.Database.GrantExecUser).AppendLine(); sb.AppendLine("GO"); sb.AppendLine(); } } catch (Exception ex) { throw; } }
public void GenerateContent(StringBuilder sb) { //if (_currentTable.IsTypeTable) return; if (_currentTable.AssociativeTable) { return; } try { sb.AppendLine("if exists(select * from sys.objects where name = '" + StoredProcedureName + "' and type = 'P' and type_desc = 'SQL_STORED_PROCEDURE')"); sb.AppendLine(" drop procedure [" + _currentTable.GetSQLSchema() + "].[" + StoredProcedureName + "]"); sb.AppendLine("GO"); sb.AppendLine(); //Just drop the procedure if no CRUD SP if (!_model.Database.UseGeneratedCRUD) { return; } sb.AppendLine("CREATE PROCEDURE [" + _currentTable.GetSQLSchema() + "].[" + StoredProcedureName + "]"); sb.AppendLine("("); sb.Append(this.BuildParameterList()); sb.AppendLine(")"); sb.AppendLine("AS"); sb.AppendLine(); sb.Append(SQLGeneratedBodyHelper.SQLUpdateBusinessObjectBody(_currentTable, _model)); sb.AppendLine("GO"); sb.AppendLine(); if (!string.IsNullOrEmpty(_model.Database.GrantExecUser)) { sb.AppendFormat("GRANT EXECUTE ON [" + _currentTable.GetSQLSchema() + "].[{0}] TO [{1}]", StoredProcedureName, _model.Database.GrantExecUser); sb.AppendLine(); sb.AppendLine("GO"); sb.AppendLine(); } } catch (Exception ex) { throw; } }
private static void AppendFullTemplate(StringBuilder sb, Table table, ModelRoot model) { try { sb.AppendLine("if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[" + GetStoredProcedureName(table, model) + "]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)"); sb.AppendLine(" drop procedure [dbo].[" + GetStoredProcedureName(table, model) + "]"); sb.AppendLine("GO"); sb.AppendLine(); sb.AppendLine("SET QUOTED_IDENTIFIER ON"); sb.AppendLine("GO"); sb.AppendLine("SET ANSI_NULLS ON"); sb.AppendLine("GO"); sb.AppendLine(); sb.AppendLine("CREATE PROCEDURE [dbo].[" + GetStoredProcedureName(table, model) + "]"); sb.AppendLine("("); sb.AppendLine(BuildParameterList(table, model)); sb.AppendLine(")"); sb.AppendLine("AS"); sb.AppendLine("SET NOCOUNT OFF;"); sb.AppendLine(); sb.Append(SQLGeneratedBodyHelper.SQLInsertBusinessObjectBody(table, model)); sb.AppendLine("GO"); sb.AppendLine(); sb.AppendLine("SET QUOTED_IDENTIFIER OFF"); sb.AppendLine("GO"); sb.AppendLine("SET ANSI_NULLS ON"); sb.AppendLine("GO"); sb.AppendLine(); if (model.Database.GrantExecUser != string.Empty) { sb.AppendFormat("GRANT EXECUTE ON [dbo].[{0}] TO [{1}]", GetStoredProcedureName(table, model), model.Database.GrantExecUser).AppendLine(); sb.AppendLine("GO"); sb.AppendLine(); } } catch (Exception ex) { throw; } }
private void AppendFullTemplate(StringBuilder sb) { try { sb.AppendLine("if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[gen_" + Globals.GetPascalName(_model, _currentTable) + "Delete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)"); sb.AppendLine(" drop procedure [dbo].[gen_" + Globals.GetPascalName(_model, _currentTable) + "Delete]"); sb.AppendLine("GO"); sb.AppendLine(); sb.AppendLine("SET QUOTED_IDENTIFIER ON "); sb.AppendLine("GO"); sb.AppendLine("SET ANSI_NULLS ON "); sb.AppendLine("GO"); sb.AppendLine(); string currentSPName = "gen_" + Globals.GetPascalName(_model, _currentTable) + "Delete"; sb.AppendLine("CREATE PROCEDURE [dbo].[" + currentSPName + "]"); sb.AppendLine("("); sb.AppendLine(" " + BuildParameterList() + ""); sb.AppendLine(")"); sb.AppendLine("AS"); sb.AppendLine("SET NOCOUNT OFF;"); sb.AppendLine(); sb.Append(SQLGeneratedBodyHelper.SQLDeleteBusinessObjectBody(_currentTable, _model)); sb.AppendLine("GO"); sb.AppendLine(); sb.AppendLine("SET QUOTED_IDENTIFIER OFF "); sb.AppendLine("GO"); sb.AppendLine("SET ANSI_NULLS ON "); sb.AppendLine("GO"); } catch (Exception ex) { throw; } }