Download presentation
Presentation is loading. Please wait.
1
An Automated Object Relational Mapper
2
What is NetTiers Discovered Indirectly While Using Mojo NetTiers = Open Source = FREE Backed by CodeSmith Template Driven Source Code Generator CodeSmith = Commercial ($99 - older versions are free, have $10 off coupon http://www.codesmithtools.com/ http://www.codesmithtools.com/ Basically is a Complex CodeSmith Template That Auto Generates N-Tier Web Applications w/ relevant CRUD, validation, unit-testing, deeploading (more later), etc.
3
CodeSmith Template Generators NetTiers NHibernate PLINQO Wilson’s ORMapper APOSA See more at http://www.codesmithtools.com/features/ frameworks.aspx http://www.codesmithtools.com/features/ frameworks.aspx
4
NetTiers Features Generates a pre-compiled solution along with separate projects and framework tiers for your application Creates Entities/Classes Based On Your Defined DB Schema - http://nettiers.com/database.ashx http://nettiers.com/database.ashx Partial/Concrete Classes nUnit testing Very robust data API Much more
5
Example Sites DSA Site Inventory - https://wsnet.colostate.edu/CWIS463/ds a-sites/ https://wsnet.colostate.edu/CWIS463/ds a-sites/ Diversity Library System - http://wsnetdev.colostate.edu/CWIS165/ home http://wsnetdev.colostate.edu/CWIS165/ home RDS Exam Intake System - http://wsnet.colostate.edu/cwis248/exam s/ http://wsnet.colostate.edu/cwis248/exam s/
6
Observations Has a bit of a learning curve (eg. Took me a few days to understand how to make url routing work in the framework) MOST IMPORTANT – Spend all the time you need to get your DB schema right before generating Know what you’re doing when regenerating solution after a db schema change I plan on using it for most any medium to large project (at least when doing web forms). Is overkill for small projects. Guessing it made a (minimum) 20 hour job take 2 hours for the DSA site inventory Lot more to learn – only used a month or two
7
Let’s Build a Site Db Schema – Nail This Down Download/Install CodeSmith & NetTiers Open the NetTiers template file (.cst) Mandatory Fields: SourceDB (YOUR SQL DB INSTANCE) MappingFile OutputDirectory (LOCATION OF PROJECT) RootNameSpace (YOUR_SITE) http://nettiers.com/GettingStarted.ashx#CB:_AB _Getting_Started_-_Required_Properties_0 http://nettiers.com/GettingStarted.ashx#CB:_AB _Getting_Started_-_Required_Properties_0
8
Let’s Build a Site Recommended Fields: SourceTables IncludeComponentLayer - ServiceLayer and DomainModel (your business layer) IncludedDatabaseFeatures – SQLServer2005 IncludeUnitTest - True DataSourceEnableTransactionDefault – False IncludeAtlasLibrary – (learned about today) IncludeAtlasToolkit
9
Let’s Build a Site Post Generation: Open VS and convert solution to rely on.net 4.0 if desired Move UI files (App_Themes, Common, MasterPage, SiteMap) over Set Default Page to Admin/Default.aspx Run solution Demo Declarative Stuff Demo Code Behind Stuff
10
To Demo Declarative Stuff Add Exam Request (note ddls generated from foreign keys) Search Export Edit UserControls - DRY Code-Behind Using the ServiceLayer API http://nettiers.com/ComponentLayer.ashx
11
Validation – ExamRequestsBase.generated /// /// Assigns validation rules to this object based on model definition. This file is overwritten upon regeneration! /// /// This method overrides the base class to add schema related validation. protected override void AddValidationRules() { //Validation rules based on database schema. ValidationRules.AddRule( CommonRules.NotNull, new ValidationRuleArgs("CourseNumber", "Course Number")); ValidationRules.AddRule( CommonRules.StringMaxLength, new CommonRules.MaxLengthRuleArgs("CourseNumber", "Course Number", 256)); ValidationRules.AddRule( CommonRules.NotNull, new ValidationRuleArgs("SectionNumber", "Section Number")); ValidationRules.AddRule( CommonRules.StringMaxLength, new CommonRules.MaxLengthRuleArgs("SectionNumber", "Section Number", 256)); ValidationRules.AddRule( CommonRules.StringMaxLength, new CommonRules.MaxLengthRuleArgs("ExamDelivery", "Exam Delivery", 256)); ValidationRules.AddRule( CommonRules.StringMaxLength, new CommonRules.MaxLengthRuleArgs("ExamReturn", "Exam Return", 256)); ValidationRules.AddRule( CommonRules.StringMaxLength, new CommonRules.MaxLengthRuleArgs("TimeAllowed", "Time Allowed", 100)); }
12
Validation – EntityRequests.cs Partial Class File Not Overwritten. More Info On Validation - http://nettiers.com/EntityLayer.ashx /**/ /// /// Validates the exam date. /// /// The target. /// The e. /// private bool ValidateExamDate(object target, Validation.ValidationRuleArgs e) { if ((this.ExamDate ?? DateTime.MinValue) < DateTime.Today) { e.Description = "The exam date must not be in the past."; return false; } return true; }
13
Going Forward Add more unit tests Add Elmah library to effectively handle application errors http://code.google.com/p/elmah/ Add Sandcastle Documentation Compiler to tie comments together http://sandcastle.codeplex.com/ CSS-based pretty forms – pForm Blueprint CSS stylesheet resets OWASP, if necessary?
14
Useful Links NetTiers on GoogleCode - http://code.google.com/p/nettiers/ http://code.google.com/p/nettiers/ NetTiers Documentation - http://nettiers.com/DocumentationPage. ashx http://nettiers.com/DocumentationPage. ashx Tlist Tips/Tricks - http://community.codesmithtools.com/Co deSmith_Community/b/nettiers/archive/2 006/03/09/10861.aspx http://community.codesmithtools.com/Co deSmith_Community/b/nettiers/archive/2 006/03/09/10861.aspx
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.