I started using BLToolkit based on performance information from http://ormeter.net/
You can define your model in simple class files, add some methods with applicable attributes, and you have DAL. Divide the table into two parts, and you can save the original class file when creating new ones to support split tables. Just make sure you create a test project that uses each method to make sure that they all work with each version.
Class
public class DirectoryListing { [PrimaryKey, Identity] public Int64 Id { get; set; } public Int64? OldId { get; set; } public Int32 CategoryId { get; set; } [Nullable] public String CompanyName { get; set; } }
General selection or table function:
[SqlQuery("SELECT * FROM Ajax_CategorySearch(@SearchString, @ResultCount)")] [Cache(MaxCacheTime = 10, IsWeak = false)] public abstract List<String> AjaxCategorySearch(String @SearchString, Int32 @ResultCount = 10);
Or use the stored proc procedure:
[ActionName("SelectById")] public abstract Model.DirectoryListing SelectById(Int64 @Id);
This will call SP DirectoryListing_SelectById
Oh, and doing things in a more classic way is also easy.
using (BIFDbManager db = new BIFDbManager()) { var output = db.SetCommand( "SQL GOES HERE", db.Parameter("@Id", 1)) .ExecuteList<DAL.Model.DirectoryListing>(); totalrecords = output.Count(); return output; }
The final piece of the puzzle is the db manager, which also supports LINQ.
public class BIFDbManager : DbManager { public BIFDbManager() : base("Connection string name") { } public Table<DirectoryListing> DirectoryListings { get { return GetTable<DirectoryListing>(); } } }
Hawxby
source share