I have a need to create the DAL & BLL for my project. I used the BusinessObjectTemplate PLINQO=> (Database -> Other ->CSharp ->BusinessObject ) to create the BLL
I need to create the DAL. I need a template that create something like the following: Can you suggest a template?
[DataObject(true)]public static class CategoryDB{ private static string GetConnectionString() { return ConfigurationManager.ConnectionStrings ["HalloweenConnectionString"].ConnectionString; }
[DataObjectMethod(DataObjectMethodType.Insert)] public static int InsertCategory(Category category) { SqlConnection con = new SqlConnection(GetConnectionString()); string ins = "INSERT INTO Categories " + " (CategoryID, ShortName, LongName) " + " VALUES(@CategoryID, @ShortName, @LongName)"; SqlCommand cmd = new SqlCommand(ins, con); cmd.Parameters.AddWithValue("CategoryID", category.CategoryID); con.Open(); int i = cmd.ExecuteNonQuery(); con.Close(); return i; }
[DataObjectMethod(DataObjectMethodType.Delete)] public static int DeleteCategory(Category category) { ............. }
[DataObjectMethod(DataObjectMethodType.Update)] public static int UpdateCategory(Category original_Category, Category category) { ............... }
Hello,
The Business Logic and Data Access Layer Logic is placed in partial classed DependentUpon files in Visual Studio. If you expand the class file node in the generated CSLA Project Solution Explorer window you will find the code.
To generate the code you are looking for, you would need to write a custom template (docs.codesmithtools.com/.../Writing+Your+First+Template) or use the following:
You could also use the stored procedure templates and command wrapper templates (both of which are located in the Database Sub Folder of Template Explorer) and fill your generated objects by using the strongly typed generated (stored procedure) wrappers.
Blake Niemyjski CodeSmith Tools, LLC. Software Development Engineer Blog: http://windowscoding.com/blogs/blake/ .NetTiers team | Visit http://www.nettiers.net
I'd recommend using one of our framework templates( www.codesmithtools.com/.../frameworks) like CSLA, PLINQO (Ling-to-SQL, nHibernate or EF), .netTiers. .netTiers and the CSLA templates will actually split your DAL and Business layers into two seperate projects while the PLINQO templates will place the two layers in the same project. I'd recommend using a template framework as it does all the work for you using the best practices like parameterized sql/stored procedures.
If you don't wish to go this route, you could also use the stored procedure templates and command wrapper templates and fill your generated objects by using the strongly typed generated (stored procedure) wrappers.
I tried all the Frameworks that you are suggesting, Some for ex: CSLA did not even generate any code other than creating a .cs file with a class name.
Hence I am asking which of the templates resembles the code that I have requested for, so I will run the template individually on each table.