Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Data Access Layer - Best design in your opinion - Object Oriented vs Efficiency

Data Access Layer - Best design in your opinion - Object Oriented vs Efficiency

Scheduled Pinned Locked Moved ASP.NET
databasehelpcsharpasp-netvisual-studio
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    ChrisFarrugia
    wrote on last edited by
    #1

    Dear All, I have been using ASP.NET for quite a while now and this questions has been in my mind for quite a long. So let us assume that I have two classes LogAction and LogEntry. The class LogAction describes an action that is found in a log such as "Login", "Deleted a record" etc. The class LogEntry implements the actual entry that will be put in the log. This class has a LogAction as one of its entries. So far so good. Now let us move to the data access layer. Suppose that I have a DAL class for both LogAction and LogEntry. In the DAL of LogAction I implement an Add method which calls a stored procedure which enters a new record in the appropriate table and also other methods such as Get methods. Now if I want to add a LogEntry in the database I have to check whether the LogAction (which is one of its member) is already in the database. If it is not, I need to insert it. The question I have is how to implement this logic. I know that for efficiency's sake, the best way would be to implement a separate stored procedure which does all these checks and entries in one connection. But for the sake of OOP it would be better if the DAL of LogEntry consults with the DAL of LogAction to see if the LogAction is already present etc... Which in your opinion is the best way to implement such logic. I know that this is a fundumental issue in enterprise application design. Many thanks for your help! Chris

    C 1 Reply Last reply
    0
    • C ChrisFarrugia

      Dear All, I have been using ASP.NET for quite a while now and this questions has been in my mind for quite a long. So let us assume that I have two classes LogAction and LogEntry. The class LogAction describes an action that is found in a log such as "Login", "Deleted a record" etc. The class LogEntry implements the actual entry that will be put in the log. This class has a LogAction as one of its entries. So far so good. Now let us move to the data access layer. Suppose that I have a DAL class for both LogAction and LogEntry. In the DAL of LogAction I implement an Add method which calls a stored procedure which enters a new record in the appropriate table and also other methods such as Get methods. Now if I want to add a LogEntry in the database I have to check whether the LogAction (which is one of its member) is already in the database. If it is not, I need to insert it. The question I have is how to implement this logic. I know that for efficiency's sake, the best way would be to implement a separate stored procedure which does all these checks and entries in one connection. But for the sake of OOP it would be better if the DAL of LogEntry consults with the DAL of LogAction to see if the LogAction is already present etc... Which in your opinion is the best way to implement such logic. I know that this is a fundumental issue in enterprise application design. Many thanks for your help! Chris

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Well, I wouldn't write a DAL for each class, I'd just write one dll. Then I'd write my proc to be as efficient as it can be. I don't NEED to create a LogAction in my C# code, I just need a return from the DB that tells me if one existed in the DB or not.

      Christian Graus Driven to the arms of OSX by Vista.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups