locked
Entity Framework RRS feed

  • Question

  • User1804952021 posted

     Hi Folks,

    Here in my company We're thinking in start a new project using ASP.Net MVC 2 and Entity Framework.

    We have some libraries to access the database, make selects, updates, deletes, insert, etc. It's old and hard to make changes. 

    These libraries are ready to make audits, inserting new records every time that the users change something in database. It means that I have two tables. The first to store the data and the second to store audits.

    Triggers can be an option, but I really don't like to use them.

    I thought to create a partial class and override methods to make this audit, but I'm not sure if is the better choice.

    Anyone can help me?

    Thanks.


    Evandro

    Hi Folks,
    Here in my company We're thinking in start a new project using ASP.Net MVC 2 and Entity Framework.
    We have some libraries to access the database, make selects, updates, deletes, insert, etc. It's old and hard to make changes. 
    These libraries are ready to make audits, inserting new records every time that the users change something in database. It means that I have two table. The first to store the data and the second to store audits.
    Triggers can be an option, but I really don't like to use them.
    I thought to create a partial class and override methods to make this audit, but I'm not sure if is the better choice.
    Anyone can help 


    Thursday, January 7, 2010 3:54 PM

Answers

All replies

  • User556320390 posted

    Hi,

    When considering about audit, you need to have a track of the user and the details of the data inserted or even modified. But if you consider to use the trigger then it seems to be a bad idea, because it may slow down the operation, and also think of some thing when you may have an option for the user for bulk insert, then...

    I would suggest you to have a different service for auditing, ie a windows service which will be used for auditing rather than the application. The windows service based of MSMQ will be good practice, just push the message into the queue and then pop the message and insert records into your audit database.


    Thursday, January 7, 2010 10:45 PM
  • User1804952021 posted

    Hi, 

    Good idea man. I really liked.

    Even using MSMQ, I still have to create a partial for each model in my project to call the method to push the message into the queue. I don't know if it's possible avoid this.

    I keep searching another ways to handle this audits, but I prefer MSMQ. 

    More suggestions?

    Thanks (by the way) =)


    Evandro

    Friday, January 8, 2010 7:18 AM
  • User1753744165 posted

    You could just create one DAL class that has all of the methods to insert into your audit tables. You could then store in your MSMQ the method name to call with the data in an XML format, and then use Reflection to invoke that method. 

     

    Or maybe Im totally off base?

     

    Nick

    Friday, January 8, 2010 8:58 AM
  • User1804952021 posted

    Hi Nick, 

    It's a good way too. It's gonna be easy because my application always will call the same method.

    I can serialize the object (in my mvc application) and send by parameter to MSMQ. The Windows Service application can get this serialized object and insert data on database through DAL.

    I never worked with MSMQ, so I'm searching googling it. I really don't know if it's possible send a serialized object to the queue.

    I'd like to attach a method to be executed every time that an object was added to Model (myMode.AddToUsers(objUser)). Anyone know if is it possible?


    Thanks.

    Friday, January 8, 2010 9:32 AM
  • User1753744165 posted

    You can send anything you want to MSMQ including Serialized objects.

    http://blogs.msdn.com/ihimmar/archive/2004/06/26/166914.aspx

     

    Nick 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, January 8, 2010 9:52 AM
  • User556320390 posted

    Hi Evandro,

    I would suggest you to use the HttpHandler class, where you call the MSMQ dll to insert the audit into queue by the broser file in asp.net.

    try it....

    Monday, January 11, 2010 11:27 PM
  • User1804952021 posted

    Thanks !

    Tuesday, January 12, 2010 10:04 AM