I am using Entity Framework for my current application. I am saving records for various pages. I need to maintain a log of all entries into database into one Master Log Table. I want that entries will save to log table automattically. Please let me know
the best way to maintain log into database...
Log in this project mean that i need to save all the actions that each user perform in some specfic tables. Insert, Update, Delete. Need to save old and new details in a different table...
Log in this project mean that i need to save all the actions that each user perform in some specfic tables. Insert, Update, Delete. Need to save old and new details in a different table...
You mean everytime when you do modifications to any record,it should be backed up?
Use this approach to main log in sql table. This I have created to direct log data by store procedure but you can change it as per your need with this same structure.
ravi010mitta...
Member
159 Points
122 Posts
Maintain entries log in database ?
May 06, 2012 12:31 PM|LINK
Hello World
I am using Entity Framework for my current application. I am saving records for various pages. I need to maintain a log of all entries into database into one Master Log Table. I want that entries will save to log table automattically. Please let me know the best way to maintain log into database...
Please let me know asap
Ravi Mittal
Code Help Code
Ken Tucker
All-Star
16797 Points
2608 Posts
MVP
Re: Maintain entries log in database ?
May 06, 2012 12:53 PM|LINK
http://weblogs.asp.net/jgalloway/archive/2008/01/27/adding-simple-trigger-based-auditing-to-your-sql-server-database.aspx
Space Coast .Net User Group
ravi010mitta...
Member
159 Points
122 Posts
Re: Maintain entries log in database ?
May 07, 2012 10:30 AM|LINK
thanks for reply sir...will you please elaborate the procedure little bit more...hows that works
Ravi Mittal
Code Help Code
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Maintain entries log in database ?
May 08, 2012 01:31 AM|LINK
Hello:)
What's log?What do you want to achieve?
Why?
Reguards!
teguhyuliant...
Participant
1370 Points
372 Posts
Re: Maintain entries log in database ?
May 08, 2012 02:08 AM|LINK
Using framework for your application, you must be know first about framework detail. Please refer the link below, hope this will help your problem.
http://www.webhostforasp.net/blog/net-technology/the-new-net-ajax-framework-3-0/
ravi010mitta...
Member
159 Points
122 Posts
Re: Maintain entries log in database ?
May 08, 2012 04:25 AM|LINK
Log in this project mean that i need to save all the actions that each user perform in some specfic tables. Insert, Update, Delete. Need to save old and new details in a different table...
Ravi Mittal
Code Help Code
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Maintain entries log in database ?
May 08, 2012 04:52 AM|LINK
You mean everytime when you do modifications to any record,it should be backed up?
ravi010mitta...
Member
159 Points
122 Posts
Re: Maintain entries log in database ?
May 08, 2012 05:08 AM|LINK
Ya along with the old and new entry if any user update the record from application or manually from database
Ravi Mittal
Code Help Code
TimoYang
Contributor
3732 Points
1275 Posts
Re: Maintain entries log in database ?
May 08, 2012 05:51 AM|LINK
Use this, plzzzzzzzzzzzz……:
foreach (ObjectStateEntry entry in ((ObjectContext)sender).ObjectStateManager.GetObjectStateEntries(EntityState.Modified)) { if (!entry.IsRelationship) { if (entry.GetModifiedProperties().Count(p => p == "CreatedBy") > 0) { Guid cb = entry.OriginalValues.GetGuid(entry.OriginalValues.GetOrdinal("CreatedBy")); PropertyInfo createdBy = entry.Entity.GetType().GetProperty("CreatedBy"); createdBy.SetValue(entry.Entity, cb, null); } if (entry.GetModifiedProperties().Count(p => p == "CreatedDate") > 0) { DateTime cd = entry.OriginalValues.GetDateTime(entry.OriginalValues.GetOrdinal("CreatedDate")); PropertyInfo createdDate = entry.Entity.GetType().GetProperty("CreatedDate"); createdDate.SetValue(entry.Entity, cd, null); } } }amitpatel.it
Star
7918 Points
1861 Posts
Re: Maintain entries log in database ?
May 08, 2012 05:56 AM|LINK
Use this approach to main log in sql table. This I have created to direct log data by store procedure but you can change it as per your need with this same structure.
http://amitpatelit.com/2011/05/06/maintaining-a-log-of-database-changes/
MCPD Enterprise and Web Application
MCTS Web, Window and Enterprise Application