suppress the generation of the return model, and instead return the entity. // Example: Proc name Return this entity type instead //StoredProcedureReturnTypes.Add("SalesByYear", "SummaryOfSalesByYear"); // Callbacks ********************************************************************************************************************** // This method will be called right before we write the POCO header.
Action<Table> WritePocoClassAttributes = t => { if (UseDataAnnotations) { foreach (var dataAnnotation in t.DataAnnotations) { WriteLine(" [" + dataAnnotation + "]"); } } // if(t.ClassName.StartsWith("Order")) // WriteLine(" [SomeAttribute]");
}; // Writes optional base classes
Func<Table, string> WritePocoBaseClasses = t => { //if (t.ClassName == "User") // return ": IdentityUser<int, CustomUserLogin, CustomUserRole, CustomUserClaim>"; // Or use the maker class to dynamically build more complex definitions
/* Example: var r = new BaseClassMaker("POCO.Sample.Data.MetaModelObject"); r.AddInterface("POCO.Sample.Data.IObjectWithTableName"); r.AddInterface("POCO.Sample.Data.IObjectWithId", t.Columns.Any(x => x.IsPrimaryKey && !x.IsNullable && x.NameHumanCase.Equals("Id", StringComparison.InvariantCultureIgnoreCase) && x.PropertyType == "long")); r.AddInterface("POCO.Sample.Data.IObjectWithUserId", t.Columns.Any(x => !x.IsPrimaryKey && !x.IsNullable && x.NameHumanCase.Equals("UserId", StringComparison.InvariantCultureIgnoreCase) && x.PropertyType == "long")); return r.ToString(); */
return ""; }; // Writes any boilerplate stuff
Action<Table> WritePocoBaseClassBody = t => { // Do nothing by default // Example: // WriteLine(" // " + t.ClassName);
}; Func<Column, string> WritePocoColumn = c => { bool commentWritten = false; if((IncludeExtendedPropertyComments == CommentsStyle.InSummaryBlock || IncludeComments == CommentsStyle.InSummaryBlock) && !string.IsNullOrEmpty(c.SummaryComments)) { WriteLine(string.Empty); WriteLine(" ///<summary>"); WriteLine(" /// {0}", System.Security.SecurityElement.Escape(c.SummaryComments)); WriteLine(" ///</summary>"); commentWritten = true; } if (UseDataAnnotations) { if(c.Ordinal > 1 && !commentWritten) WriteLine(string.Empty); // Leave a blank line before the next property
foreach (var dataAnnotation in c.DataAnnotations) { WriteLine(" [" + dataAnnotation + "]"); } } // Example of adding a [Required] data annotation attribute to all non-null fields //if (!c.IsNullable) // return " [System.ComponentModel.DataAnnotations.Required] " + c.Entity;
return " " + c.Entity; }; ForeignKeyFilter = (ForeignKey fk) => { // Return null to exclude this foreign key, or set IncludeReverseNavigation = false // to include the foreign key but not generate reverse navigation properties. // Example, to exclude all foreign keys for the Categories table, use: // if (fk.PkTableName == "Categories") // return null; // Example, to exclude reverse navigation properties for t |