Project DescriptionYour entity classes/data access layer should be the easiest part of your application, not some bloated mess of academic wankery. The UnifiedASP DAL gives you an easy way to structure your entity/data objects and execute SQL stored procedures.
(C-Sharp (default) and VB.Net downloads available. VB.Net is available under View All Downloads)
It supports the two most common ways your application consumes data:
- bound to a control
- or iterated in business logic
Examples:
Dim chambers as new UnifiedASP.Domain.Chamber
chambers.LoadAll()
grdChambers.DataSource = chambers
grdChambers.DataBind
or
Dim chambers as new UnifiedASP.Domain.Chamber
chambers.LoadAll()
While Not chambers.Eof
DoSendMonthlyEmail(chambers.EmailAddress)
chamber.MoveNext()
Wend
The UnifiedASP DAL lets you do both very easily with stored procedures and simple data classes:
Imports UnifiedASP.Utility
Namespace UnifiedASP.Domain
Public Class Chamber
Inherits UnifiedASP.Base.DomainSQL
Public ChamberId As Integer
Public ChamberName As String
Public Address As String
Public City As String
Public StateId As Integer
Public StateAbbr As String
Public StateName As String
Public ZipCode As String
Public PhoneNumber As String
Public FaxNumber As String
Public WebsiteUrl As String
Public EmailAddress As String
Public Sub LoadMe()
InitCommand("chChamber_Get")
AddParameter("ChamberId", ChamberId)
ExecCommand()
End Sub
Public Sub LoadAll()
InitCommand("chChamber_GetAll")
AddParameter("StateName", 200, StateName)
ExecCommand()
End Sub
Public Sub Save()
InitCommand("chChamber_Save")
AddParameter("ChamberId", ChamberId)
AddParameter("ChamberName", 200, ChamberName)
AddParameter("Address", 200, Address)
AddParameter("City", 200, City)
AddParameter("StateId", StateId)
AddParameter("ZipCode", 10, ZipCode)
AddParameter("PhoneNumber", 50, PhoneNumber)
AddParameter("FaxNumber", 50, FaxNumber)
AddParameter("WebsiteUrl", 200, WebsiteUrl)
ExecCommand()
End Sub
Public Sub Remove()
InitCommand("chChamber_Remove")
AddParameter("ChamberId", ChamberId)
ExecCommand()
End Sub
Public Overrides Sub Populate()
ChamberId = GetValue("ChamberId")
ChamberName = GetValue("ChamberName")
Address = GetValue("Address")
City = GetValue("City")
StateId = GetValue("StateId")
StateAbbr = GetValue("StateAbbr")
StateName = GetValue("StateName")
ZipCode = GetValue("ZipCode")
PhoneNumber = GetValue("PhoneNumber")
FaxNumber = GetValue("FaxNumber")
WebsiteUrl = GetValue("WebsiteUrl")
End Sub
Public Overrides Sub ClearValues()
ChamberId = Nothing
ChamberName = Nothing
Address = Nothing
City = Nothing
StateId = Nothing
StateAbbr = Nothing
StateName = Nothing
ZipCode = Nothing
PhoneNumber = Nothing
FaxNumber = Nothing
WebsiteUrl = Nothing
End Sub
End Class
End Namespace
All the messiness of interacting with the database is abstracted into a base class so all you have to deal with in your application are your entities, properties, and methods. In most cases, having a separate entity class and data class is repetitive and unnecessary. Why do more work than you have to?
This is the data access portion of a full framework (
http://www.unifiedasp.net) I published a few years ago. I've had a few clients recently where I can't drop in the full framework but I still try to bring in this DAL. It also works very well with ASP.Net MVC.
A good primer for using this DAL can be found at
http://www.unifiedasp.net/index.php/unifiedasp-data-access-primer/There are a couple of sample classes and some more notes in the example folder of the downloadable projects. Feel free to drop me a message through my site linked below if you have questions.
Hope it gives you an option that's much easier to live with than what's common practice these days.
Scott Drake
http://www.scottdrakesoftware.com