From jeff.developer at gmail.com Tue Apr 2 09:43:22 2013 From: jeff.developer at gmail.com (Jeff B) Date: Tue, 2 Apr 2013 09:43:22 -0500 Subject: [dba-VB] Older Access Books (Cross Posted) Message-ID: Anyone know what I can do with old Access books (like the Access 2000 Developer?s Handbook)? I also have some unused MCSD / MCSA books (I bought them for myself, then signed up for a Boot Camp and they used the exact same books so I wound up with two sets) Jeff Barrows MCP, MCAD, MCSD ? Outbak Technologies, LLC Racine, WI jeff.developer at gmail.com From df.waters at comcast.net Tue Apr 2 11:35:30 2013 From: df.waters at comcast.net (Dan Waters) Date: Tue, 2 Apr 2013 11:35:30 -0500 Subject: [dba-VB] Hosting a .Net App (X-Posted) Message-ID: <002f01ce2fc0$176f9ce0$464ed6a0$@comcast.net> One of my customers has a parent company which contracted with a computer services company (let's call them CSC). That company is responsible for all things PC, network, servers, security, etc. They have single tool: a 5 lb. sledge. The latest is that they've 'hardened' all the servers at my client's location. But what they really did was to quarantine them. Which means that no one, including me, can use remote desktop to get at my system and data tables. I am literally locked out. Their answer is that people can still get at the files, they just can't remote in. This absolutely does not work for me at all (think running access across the internet). Unfortunately, my client is as frustrated as I am because they have zero input on this (and many other things) and zero control to prevent it. So I was thinking that perhaps I could host my .Net Windows forms click-once desktop app on a hosted server. The people at my client could log into the server using VPN or something similar, and then run my published app. This concept already works because if they are off site they can log into their network using VPN and then just open my app - which runs just as quickly remotely as it does locally. And I could log in using something equivalent to VPN/Remote Desktop to make needed changes. Can anyone provide any thoughts on this? I do have a website hosted via GoDaddy so I'm going to talk with them also. Thanks! Dan Waters From mcp2004 at mail.ru Mon Apr 15 06:22:51 2013 From: mcp2004 at mail.ru (=?UTF-8?B?U2FsYWtoZXRkaW5vdiBTaGFtaWw=?=) Date: Mon, 15 Apr 2013 15:22:51 +0400 Subject: [dba-VB] =?utf-8?q?CodeFirst=2C_DataBinding_and_audit_trailing_de?= =?utf-8?q?leted_items_on_client_side?= Message-ID: <1366024971.329024624@f25.mail.ru> Hi All -- I have made a sample app here using CodeFirst ADO.NET EF approach. It works well. I just cannot currently solve one issue, namely: - to audit trail items deleted in a bound DataGridView. I have found how to find deleted items in a bound DbSet<{{EntityType}} list but the issue is that deleted item gets its item Id (surrogate key) zeroed, so my audit trailing can't be used to find corresponding database record.? Any ideas? Thank you. -- Shamil From mcp2004 at mail.ru Mon Apr 15 06:36:04 2013 From: mcp2004 at mail.ru (=?UTF-8?B?U2FsYWtoZXRkaW5vdiBTaGFtaWw=?=) Date: Mon, 15 Apr 2013 15:36:04 +0400 Subject: [dba-VB] =?utf-8?q?_Performance_Considerations_=28Entity_Framewor?= =?utf-8?q?k=29?= Message-ID: <1366025764.557183905@f25.mail.ru> Hi All -- FYI: Here is a good MSDN article: Performance Considerations (Entity Framework) http://msdn.microsoft.com/en-us/library/cc853327.aspx See also the links at the bottom of that article. * Exploring the Performance of the ADO.NET Entity Framework - Part 1 ? * Exploring the Performance of the ADO.NET Entity Framework ? Part 2 ? * ADO.NET Entity Framework Performance Comparison -- Shamil From mcp2004 at mail.ru Mon Apr 15 15:39:19 2013 From: mcp2004 at mail.ru (=?UTF-8?B?U2FsYWtoZXRkaW5vdiBTaGFtaWw=?=) Date: Tue, 16 Apr 2013 00:39:19 +0400 Subject: [dba-VB] =?utf-8?q?CodeFirst=2C_DataBinding_and_audit_trailing_de?= =?utf-8?q?leted_items_on_client_side?= In-Reply-To: References: <1366024971.329024624@f25.mail.ru> Message-ID: <1366058359.473696441@f379.i.mail.ru> Hi Scott -- I'm trying to audit trail *individual* changes while the rows' editions, additions, deletions are done using a DataGridView?bound to a DbSet<{{EntityType}}> ?of a {{CustomModel}}Container: DbContext IOW before they get saved/committed to the backend. I have set custom events processing for the BidindingSource.ListChanged event and for the DataGridView.RowsRemoved event. They together allow me to audit trail changes on client side. But I suppose this custom audit trail solution is a bit tricky to be true - there should be a simpler one? I can also audit trail the changes in a "batch" mode before they get saved to the backend by using .SaveChanges method of?a {{CustomModel}}Container: DbContext then custom events processing of the?BidindingSource.ListChanged event and of the DataGridView.RowsRemoved isn't needed. But I'd prefer to have an option to audit trail *individual* changes using simpler solution than I have currently got working. I must note that the subject issue isn't currently needed here to be solved for any real life project - it's more a "research" kind of issue helping to learn better how bound WinForms communicate with their "model first" datasources... Thank you. -- Shamil ???????????, 15 ?????? 2013, 10:50 -04:00 ?? Scott Marcus : >Where are you trying to perform the audit routines? Are you doing the audit changes after saving the changes to your model. Ideally, you would be making the audit records within the same savechanges context (since all changes are within the same transaction) so that any error to the savechanges does not create an audit of the changes that were rolled back. > >-----Original Message----- >From: dba-vb-bounces at databaseadvisors.com [mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of Salakhetdinov Shamil >Sent: Monday, April 15, 2013 7:23 AM >To: Discussion concerning Visual Basic and related programming issues. >Subject: [dba-VB] CodeFirst, DataBinding and audit trailing deleted items on client side > >?Hi All -- > >I have made a sample app here using CodeFirst ADO.NET EF approach. It works well. I just cannot currently solve one issue, namely: > >- to audit trail items deleted in a bound DataGridView. > >I have found how to find deleted items in a bound DbSet<{{EntityType}} list but the issue is that deleted item gets its item Id (surrogate key) zeroed, so my audit trailing can't be used to find corresponding database record. > >Any ideas? > >Thank you. > >-- Shamil >_______________________________________________ >dba-VB mailing list >dba-VB at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-vb >http://www.databaseadvisors.com > > >NOTICE: This electronic mail transmission is for the use of the named individual or entity to which it is directed and may contain information that is privileged or confidential. If you are not the intended recipient, any disclosure, copying, distribution or use of the contents of any information contained herein is prohibited. If you have received this electronic mail transmission in error, delete it from your system without copying or forwarding it, and notify the sender of the error by replying via email or calling TSS Technologies at (513) 772-7000, so that our address record can be corrected. >Any information included in this email is provided on an ?as is? and ?where as? basis, and TSS Technologies makes no representations or warranties of any kind with respect to the completeness or accuracy of the information contained in this email. From tsm at zoomtown.com Mon Apr 15 17:50:07 2013 From: tsm at zoomtown.com (Scott Marcus) Date: Mon, 15 Apr 2013 18:50:07 -0400 Subject: [dba-VB] CodeFirst, DataBinding and audit trailing deleted items on client side In-Reply-To: <1366058359.473696441@f379.i.mail.ru> References: <1366024971.329024624@f25.mail.ru> <1366058359.473696441@f379.i.mail.ru> Message-ID: <486A7847-225A-4158-80F1-F9F69A1967B5@zoomtown.com> Before calling the save changes method, add the audit record to the context and change its state to modified. Then call the save changes method. i.e. (in c#) Audit audit = new Audit({UserName = username, RecordID = changedRecordID}); context.Entry(audit).State = EntityState.Modified; context.SaveChanges; Sent from my iPad On Apr 15, 2013, at 4:39 PM, Salakhetdinov Shamil wrote: > Hi Scott -- > > I'm trying to audit trail *individual* changes while the rows' editions, additions, deletions are done using a DataGridView bound to a DbSet<{{EntityType}}> of a {{CustomModel}}Container: DbContext IOW before they get saved/committed to the backend. > > I have set custom events processing for the BidindingSource.ListChanged event and for the DataGridView.RowsRemoved event. They together allow me to audit trail changes on client side. But I suppose this custom audit trail solution is a bit tricky to be true - there should be a simpler one? > > I can also audit trail the changes in a "batch" mode before they get saved to the backend by using .SaveChanges method of a {{CustomModel}}Container: DbContext then custom events processing of the BidindingSource.ListChanged event and of the DataGridView.RowsRemoved isn't needed. But I'd prefer to have an option to audit trail *individual* changes using simpler solution than I have currently got working. > > I must note that the subject issue isn't currently needed here to be solved for any real life project - it's more a "research" kind of issue helping to learn better how bound WinForms communicate with their "model first" datasources... > > Thank you. > > -- Shamil > > > ???????????, 15 ?????? 2013, 10:50 -04:00 ?? Scott Marcus : >> Where are you trying to perform the audit routines? Are you doing the audit changes after saving the changes to your model. Ideally, you would be making the audit records within the same savechanges context (since all changes are within the same transaction) so that any error to the savechanges does not create an audit of the changes that were rolled back. >> >> -----Original Message----- >> From: dba-vb-bounces at databaseadvisors.com [mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of Salakhetdinov Shamil >> Sent: Monday, April 15, 2013 7:23 AM >> To: Discussion concerning Visual Basic and related programming issues. >> Subject: [dba-VB] CodeFirst, DataBinding and audit trailing deleted items on client side >> >> Hi All -- >> >> I have made a sample app here using CodeFirst ADO.NET EF approach. It works well. I just cannot currently solve one issue, namely: >> >> - to audit trail items deleted in a bound DataGridView. >> >> I have found how to find deleted items in a bound DbSet<{{EntityType}} list but the issue is that deleted item gets its item Id (surrogate key) zeroed, so my audit trailing can't be used to find corresponding database record. >> >> Any ideas? >> >> Thank you. >> >> -- Shamil >> _______________________________________________ >> dba-VB mailing list >> dba-VB at databaseadvisors.com >> http://databaseadvisors.com/mailman/listinfo/dba-vb >> http://www.databaseadvisors.com >> >> >> NOTICE: This electronic mail transmission is for the use of the named individual or entity to which it is directed and may contain information that is privileged or confidential. If you are not the intended recipient, any disclosure, copying, distribution or use of the contents of any information contained herein is prohibited. If you have received this electronic mail transmission in error, delete it from your system without copying or forwarding it, and notify the sender of the error by replying via email or calling TSS Technologies at (513) 772-7000, so that our address record can be corrected. >> Any information included in this email is provided on an ?as is? and ?where as? basis, and TSS Technologies makes no representations or warranties of any kind with respect to the completeness or accuracy of the information contained in this email. > > _______________________________________________ > dba-VB mailing list > dba-VB at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-vb > http://www.databaseadvisors.com > From mcp2004 at mail.ru Tue Apr 16 03:39:38 2013 From: mcp2004 at mail.ru (=?UTF-8?B?U2FsYWtoZXRkaW5vdiBTaGFtaWw=?=) Date: Tue, 16 Apr 2013 12:39:38 +0400 Subject: [dba-VB] =?utf-8?q?CodeFirst=2C_DataBinding_and_audit_trailing_de?= =?utf-8?q?leted_items_on_client_side?= In-Reply-To: <486A7847-225A-4158-80F1-F9F69A1967B5@zoomtown.com> References: <1366024971.329024624@f25.mail.ru> <1366058359.473696441@f379.i.mail.ru> <486A7847-225A-4158-80F1-F9F69A1967B5@zoomtown.com> Message-ID: <1366101578.695415048@f398.i.mail.ru> Hi Scott -- I actually have to look for EntityState.Modified,??EntityState.Added and?EntityState.Deleted which are "automagically" set "behind the scene" for edited items while data is edited in a DataGridView bound to DBSet.Local Here is a test code I use: MyTestEntitiesContainer _context; IOrderedQueryable _list; private void loadData() { ? ?_context = new MyTestEntitiesContainer(); ? ?_list = from s in _context.MyTestEntity?orderby s.Name select s; ? ?_list.Load(); ? ? ? myTestEntityBindingSource.DataSource = _context.MyTestEntity.Local; } As it happens (if I'm not mistaked) items with?EntityState.Modified and ?EntityState.Added can be found in?_context.MyTestEntity.Local but items with?EntityState.Deleted can be only found in _list. And as I have noted I wanted to get audit trailing facility to work on currently edited (changed, added, deleted) item not by investigating the whole?_context.MyTestEntity.Local or _list. Anyway it's not urgent issue. I will check it more n the coming days. Your comments are very welcome. Thank you. -- Shamil ???????????, 15 ?????? 2013, 18:50 -04:00 ?? Scott Marcus : >Before calling the save changes method, add the audit record to the context and change its state to modified. Then call the save changes method. > >i.e. (in c#) > >Audit audit = new Audit({UserName = username, RecordID = changedRecordID}); >context.Entry(audit).State = EntityState.Modified; >context.SaveChanges; > >Sent from my iPad > >On Apr 15, 2013, at 4:39 PM, Salakhetdinov Shamil < mcp2004 at mail.ru > wrote: > >> Hi Scott -- >> >> I'm trying to audit trail *individual* changes while the rows' editions, additions, deletions are done using a DataGridView bound to a DbSet<{{EntityType}}> of a {{CustomModel}}Container: DbContext IOW before they get saved/committed to the backend. >> >> I have set custom events processing for the BidindingSource.ListChanged event and for the DataGridView.RowsRemoved event. They together allow me to audit trail changes on client side. But I suppose this custom audit trail solution is a bit tricky to be true - there should be a simpler one? >> >> I can also audit trail the changes in a "batch" mode before they get saved to the backend by using .SaveChanges method of a {{CustomModel}}Container: DbContext then custom events processing of the BidindingSource.ListChanged event and of the DataGridView.RowsRemoved isn't needed. But I'd prefer to have an option to audit trail *individual* changes using simpler solution than I have currently got working. >> >> I must note that the subject issue isn't currently needed here to be solved for any real life project - it's more a "research" kind of issue helping to learn better how bound WinForms communicate with their "model first" datasources... >> >> Thank you. >> >> -- Shamil >> >> >> ???????????, 15 ?????? 2013, 10:50 -04:00 ?? Scott Marcus < scott.marcus at tsstech.com >: >>> Where are you trying to perform the audit routines? Are you doing the audit changes after saving the changes to your model. Ideally, you would be making the audit records within the same savechanges context (since all changes are within the same transaction) so that any error to the savechanges does not create an audit of the changes that were rolled back. >>> >>> -----Original Message----- >>> From: dba-vb-bounces at databaseadvisors.com [mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of Salakhetdinov Shamil >>> Sent: Monday, April 15, 2013 7:23 AM >>> To: Discussion concerning Visual Basic and related programming issues. >>> Subject: [dba-VB] CodeFirst, DataBinding and audit trailing deleted items on client side >>> >>> Hi All -- >>> >>> I have made a sample app here using CodeFirst ADO.NET EF approach. It works well. I just cannot currently solve one issue, namely: >>> >>> - to audit trail items deleted in a bound DataGridView. >>> >>> I have found how to find deleted items in a bound DbSet<{{EntityType}} list but the issue is that deleted item gets its item Id (surrogate key) zeroed, so my audit trailing can't be used to find corresponding database record. >>> >>> Any ideas? >>> >>> Thank you. >>> >>> -- Shamil >>> _______________________________________________ >>> dba-VB mailing list >>> dba-VB at databaseadvisors.com >>> http://databaseadvisors.com/mailman/listinfo/dba-vb >>> http://www.databaseadvisors.com >>> >>> >>> NOTICE: This electronic mail transmission is for the use of the named individual or entity to which it is directed and may contain information that is privileged or confidential. If you are not the intended recipient, any disclosure, copying, distribution or use of the contents of any information contained herein is prohibited. If you have received this electronic mail transmission in error, delete it from your system without copying or forwarding it, and notify the sender of the error by replying via email or calling TSS Technologies at (513) 772-7000, so that our address record can be corrected. >>> Any information included in this email is provided on an ?as is? and ?where as? basis, and TSS Technologies makes no representations or warranties of any kind with respect to the completeness or accuracy of the information contained in this email. >> >> _______________________________________________ >> dba-VB mailing list >> dba-VB at databaseadvisors.com >> http://databaseadvisors.com/mailman/listinfo/dba-vb >> http://www.databaseadvisors.com >> From mcp2004 at mail.ru Tue Apr 16 03:42:28 2013 From: mcp2004 at mail.ru (=?UTF-8?B?U2FsYWtoZXRkaW5vdiBTaGFtaWw=?=) Date: Tue, 16 Apr 2013 12:42:28 +0400 Subject: [dba-VB] =?utf-8?q?=2ENET_-_ADO=2ENET_Entity_Framework_=3A_Queryi?= =?utf-8?q?ng_metadata?= Message-ID: <1366101748.869550137@f398.i.mail.ru> Hi All -- FYI: Here is a good article (the best I have seen so far) with many code snippets on querying ADO.NET EF metadata: .NET - ADO.NET Entity Framework : Querying metadata ?http://www.scip.be/index.php?Page=ArticlesNET24 Thank you. -- Shamil From scott.marcus at tsstech.com Tue Apr 16 08:16:28 2013 From: scott.marcus at tsstech.com (Scott Marcus) Date: Tue, 16 Apr 2013 09:16:28 -0400 Subject: [dba-VB] CodeFirst, DataBinding and audit trailing deleted items on client side In-Reply-To: <1366101578.695415048@f398.i.mail.ru> References: <1366024971.329024624@f25.mail.ru> <1366058359.473696441@f379.i.mail.ru> <486A7847-225A-4158-80F1-F9F69A1967B5@zoomtown.com> <1366101578.695415048@f398.i.mail.ru> Message-ID: I guess I'm not sure what you mean by individual changes. SaveChanges should happen at your whim and whether it is to one record or many records is your call. Perhaps there is a misunderstanding since I am using an MVC repository method in ASP.NET. I just thought entity framework behaves the same regardless the environment. Here is an example... public class MyModelRepository : IMyModelRepository { private EFDbContext context = new EFDbContext(); public IQueryable MyModels { get { return context.MyModels; } } public void Save(MyModel someRecord, int loginID, string changesMade = "Record Created") { DateTime changesMadeDateAndTime = DateTime.Now; AuditModel auditRecord = new AuditModel { WhoDoneIt = loginID, WhatDidTheyDo = changesMade, WhenDidTheyDoIt = changesMadeDateAndTime }; context.AuditRecordModels.Add(auditRecord); // if you wanted, you could add more records and change more records before you call SaveChanges // you would probably not do it in this function but in another overloaded function // that handles multiple record changes context.SaveChanges(); //saves the changes to someRecord and adds the auditRecord all in one transaction } public void Delete(MyModel someRecord, int loginID) { DateTime deletedDateAndTime = DateTime.Now; AuditModel auditRecord = new AuditModel { WhoDoneIt = loginID, WhatDidTheyDo = "Deleted MyModel Record: " + someRecord.RecordID, WhenDidTheyDoIt = deletedDateAndTime }; context.AuditRecordModels.Add(auditRecord); context.MyModels.Remove(someRecord); context.SaveChanges(); //now perform the work that adds the audit record and removes someRecord all in one transaction } } Scott -----Original Message----- From: dba-vb-bounces at databaseadvisors.com [mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of Salakhetdinov Shamil Sent: Tuesday, April 16, 2013 4:40 AM To: Discussion concerning Visual Basic and related programming issues. Subject: Re: [dba-VB] CodeFirst, DataBinding and audit trailing deleted items on client side Hi Scott -- I actually have to look for EntityState.Modified,??EntityState.Added and?EntityState.Deleted which are "automagically" set "behind the scene" for edited items while data is edited in a DataGridView bound to DBSet.Local Here is a test code I use: MyTestEntitiesContainer _context; IOrderedQueryable _list; private void loadData() { ? ?_context = new MyTestEntitiesContainer(); ? ?_list = from s in _context.MyTestEntity?orderby s.Name select s; ? ?_list.Load(); ? ? myTestEntityBindingSource.DataSource = _context.MyTestEntity.Local; } As it happens (if I'm not mistaked) items with?EntityState.Modified and ?EntityState.Added can be found in?_context.MyTestEntity.Local but items with?EntityState.Deleted can be only found in _list. And as I have noted I wanted to get audit trailing facility to work on currently edited (changed, added, deleted) item not by investigating the whole?_context.MyTestEntity.Local or _list. Anyway it's not urgent issue. I will check it more n the coming days. Your comments are very welcome. Thank you. -- Shamil ???????????, 15 ?????? 2013, 18:50 -04:00 ?? Scott Marcus : >Before calling the save changes method, add the audit record to the context and change its state to modified. Then call the save changes method. > >i.e. (in c#) > >Audit audit = new Audit({UserName = username, RecordID = >changedRecordID}); context.Entry(audit).State = EntityState.Modified; >context.SaveChanges; > >Sent from my iPad > >On Apr 15, 2013, at 4:39 PM, Salakhetdinov Shamil < mcp2004 at mail.ru > wrote: > >> Hi Scott -- >> >> I'm trying to audit trail *individual* changes while the rows' editions, additions, deletions are done using a DataGridView bound to a DbSet<{{EntityType}}> of a {{CustomModel}}Container: DbContext IOW before they get saved/committed to the backend. >> >> I have set custom events processing for the BidindingSource.ListChanged event and for the DataGridView.RowsRemoved event. They together allow me to audit trail changes on client side. But I suppose this custom audit trail solution is a bit tricky to be true - there should be a simpler one? >> >> I can also audit trail the changes in a "batch" mode before they get saved to the backend by using .SaveChanges method of a {{CustomModel}}Container: DbContext then custom events processing of the BidindingSource.ListChanged event and of the DataGridView.RowsRemoved isn't needed. But I'd prefer to have an option to audit trail *individual* changes using simpler solution than I have currently got working. >> >> I must note that the subject issue isn't currently needed here to be solved for any real life project - it's more a "research" kind of issue helping to learn better how bound WinForms communicate with their "model first" datasources... >> >> Thank you. >> >> -- Shamil >> >> >> ???????????, 15 ?????? 2013, 10:50 -04:00 ?? Scott Marcus < scott.marcus at tsstech.com >: >>> Where are you trying to perform the audit routines? Are you doing the audit changes after saving the changes to your model. Ideally, you would be making the audit records within the same savechanges context (since all changes are within the same transaction) so that any error to the savechanges does not create an audit of the changes that were rolled back. >>> >>> -----Original Message----- >>> From: dba-vb-bounces at databaseadvisors.com >>> [mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of >>> Salakhetdinov Shamil >>> Sent: Monday, April 15, 2013 7:23 AM >>> To: Discussion concerning Visual Basic and related programming issues. >>> Subject: [dba-VB] CodeFirst, DataBinding and audit trailing deleted >>> items on client side >>> >>> Hi All -- >>> >>> I have made a sample app here using CodeFirst ADO.NET EF approach. It works well. I just cannot currently solve one issue, namely: >>> >>> - to audit trail items deleted in a bound DataGridView. >>> >>> I have found how to find deleted items in a bound DbSet<{{EntityType}} list but the issue is that deleted item gets its item Id (surrogate key) zeroed, so my audit trailing can't be used to find corresponding database record. >>> >>> Any ideas? >>> >>> Thank you. >>> >>> -- Shamil >>> _______________________________________________ >>> dba-VB mailing list >>> dba-VB at databaseadvisors.com >>> http://databaseadvisors.com/mailman/listinfo/dba-vb >>> http://www.databaseadvisors.com >>> >>> >>> NOTICE: This electronic mail transmission is for the use of the named individual or entity to which it is directed and may contain information that is privileged or confidential. If you are not the intended recipient, any disclosure, copying, distribution or use of the contents of any information contained herein is prohibited. If you have received this electronic mail transmission in error, delete it from your system without copying or forwarding it, and notify the sender of the error by replying via email or calling TSS Technologies at (513) 772-7000, so that our address record can be corrected. >>> Any information included in this email is provided on an ?as is? and ?where as? basis, and TSS Technologies makes no representations or warranties of any kind with respect to the completeness or accuracy of the information contained in this email. >> >> _______________________________________________ >> dba-VB mailing list >> dba-VB at databaseadvisors.com >> http://databaseadvisors.com/mailman/listinfo/dba-vb >> http://www.databaseadvisors.com >> _______________________________________________ dba-VB mailing list dba-VB at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-vb http://www.databaseadvisors.com From mcp2004 at mail.ru Tue Apr 16 20:39:26 2013 From: mcp2004 at mail.ru (=?UTF-8?B?U2FsYWtoZXRkaW5vdiBTaGFtaWw=?=) Date: Wed, 17 Apr 2013 05:39:26 +0400 Subject: [dba-VB] =?utf-8?q?CodeFirst=2C_DataBinding_and_audit_trailing_de?= =?utf-8?q?leted_items_on_client_side?= In-Reply-To: References: <1366024971.329024624@f25.mail.ru> <1366101578.695415048@f398.i.mail.ru> Message-ID: <1366162766.215615498@f53.mail.ru> Hi Scott -- Thank you for your sample. I have prepared mine, which I will post here in several subsequent posts as one posting limit is 20KB. By "individual changes" I mean *all* the data changes happened between data load and data saving, And I wanted to "capture" that individual data changes as soon as they happen not before .SaveChanges() call. ???????, 16 ?????? 2013, 9:16 -04:00 ?? Scott Marcus : >I guess I'm not sure what you mean by individual changes. SaveChanges should happen at your whim and whether it is to one record or many records is your call. Perhaps there is a misunderstanding since I am using an MVC repository method in ASP.NET. I just thought entity framework behaves the same regardless the environment. > >Here is an example... > >????public class MyModelRepository : IMyModelRepository >????{ >????????private EFDbContext context = new EFDbContext(); > >????????public IQueryable MyModels >????????{ >????????????get { return context.MyModels; } >????????} > >????????public void Save(MyModel someRecord, int loginID, string changesMade = "Record Created") >????????{ >????????????DateTime changesMadeDateAndTime = DateTime.Now; >????????????AuditModel auditRecord = new AuditModel >????????????{ >????????????????WhoDoneIt = loginID, >????????????????WhatDidTheyDo = changesMade, >????????????????WhenDidTheyDoIt = changesMadeDateAndTime >????????????}; >????????????context.AuditRecordModels.Add(auditRecord); > >???????????// if you wanted, you could add more records and change more records before you call SaveChanges >???????????// you would probably not do it in this function but in another overloaded function >???????????// that handles multiple record changes > >????????????context.SaveChanges(); //saves the changes to someRecord and adds the auditRecord all in one transaction >????????} > >????????public void Delete(MyModel someRecord, int loginID) >????????{ >????????????DateTime deletedDateAndTime = DateTime.Now; >????????????AuditModel auditRecord = new AuditModel >????????????{ >????????????????WhoDoneIt = loginID, >????????????????WhatDidTheyDo = "Deleted MyModel Record: " + someRecord.RecordID, >????????????????WhenDidTheyDoIt = deletedDateAndTime >????????????}; >????????????context.AuditRecordModels.Add(auditRecord); >????????????context.MyModels.Remove(someRecord); >????????????context.SaveChanges(); //now perform the work that adds the audit record and removes someRecord all in one transaction >????????} >????} > > >Scott <<< skipped >>> From mcp2004 at mail.ru Tue Apr 16 20:41:56 2013 From: mcp2004 at mail.ru (=?UTF-8?B?U2FsYWtoZXRkaW5vdiBTaGFtaWw=?=) Date: Wed, 17 Apr 2013 05:41:56 +0400 Subject: [dba-VB] =?utf-8?q?CodeFirst=2C_DataBinding_and_audit_trailing_de?= =?utf-8?q?leted_items_on_client_side?= In-Reply-To: <1366162766.215615498@f53.mail.ru> References: <1366024971.329024624@f25.mail.ru> <1366162766.215615498@f53.mail.ru> Message-ID: <1366162916.969479111@f372.mail.ru> Sample code part I: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data.Entity; using System.Linq; using System.Windows.Forms; namespace TestWindowsFormsApplication1 { public class GenericEntityGridViewHandler : IDisposable where C : DbContext where T : class { private string _idFieldName; private string _altKeyFieldName; private string _dataLoadSql; public GenericEntityGridViewHandler( DataGridView entityDataGridView, BindingSource entityBindingSource, string dataLoadSql, string idFieldName = "Id", string altKeyFieldName = "Name") { _entityDataGridView = entityDataGridView; _entityBindingSource = entityBindingSource; _entityBindingSource.ListChanged += new ListChangedEventHandler(_entityBindingSource_ListChanged); _entityDataGridView.RowsRemoved += new DataGridViewRowsRemovedEventHandler(_entityDataGridView_RowsRemoved); _idFieldName = idFieldName; _altKeyFieldName = altKeyFieldName; _dataLoadSql = dataLoadSql; } private DataGridView _entityDataGridView; private BindingSource _entityBindingSource; private C _context; private IQueryable _dataSource; private bool _loadInProgress; public void LoadData() { try { _loadInProgress = true; _context = (C)Activator.CreateInstance(typeof(C)); _dataSource = _context.Set(typeof(T)).SqlQuery(_dataLoadSql).OfType().AsQueryable(); _dataSource.Load(); _entityBindingSource.DataSource = _context.Set(typeof(T)).Local; _auditTrailItems = new Dictionary(); } finally { _loadInProgress = false; } } public class AuditTrailItem { public AuditTrailItem(System.Data.EntityState itemState, T item, string itemKey) { this.ItemState = itemState; this.Item = item; this.ItemKey = itemKey; } public System.Data.EntityState ItemState { get; private set; } public T Item { get; private set; } public string ItemKey { get; private set; } } // keeps individual data changes audit trail public Dictionary AuditTrailItems { get { return _auditTrailItems; } } private Dictionary _auditTrailItems; private void addAuditTrailItem(T item, System.Data.EntityState state, Dictionary auditTrailItems) { string key = getKeyValue(item); if (string.IsNullOrWhiteSpace(key)) return; key = string.Format("{0}:{1}", state, key); if (auditTrailItems.ContainsKey(key)) return; auditTrailItems.Add(key, new AuditTrailItem(state, item, key)); } private void auditTrailModelChanges(ref Dictionary auditTrailItems) { if (auditTrailItems == null) auditTrailItems = new Dictionary(); IEnumerable[] checkStateSources = { (IEnumerable)_context.Set(typeof(T)).Local, (IEnumerable)_dataSource }; foreach (IEnumerable checkStateSource in checkStateSources) { foreach (T item in checkStateSource) { switch (_context.Entry(item).State) { case System.Data.EntityState.Added: case System.Data.EntityState.Modified: case System.Data.EntityState.Deleted: addAuditTrailItem(item, _context.Entry(item).State, auditTrailItems); break; } } } } --- to be continued --- ?????, 17 ?????? 2013, 5:39 +04:00 ?? Salakhetdinov Shamil : >Hi Scott -- > >Thank you for your sample. I have prepared mine, which I will post here in several subsequent posts as one posting limit is 20KB. > >By "individual changes" I mean *all* the data changes happened between data load and data saving, And I wanted to "capture" that individual data changes as soon as they happen not before .SaveChanges() call. <<< skipped >>> > From mcp2004 at mail.ru Tue Apr 16 20:44:41 2013 From: mcp2004 at mail.ru (=?UTF-8?B?U2FsYWtoZXRkaW5vdiBTaGFtaWw=?=) Date: Wed, 17 Apr 2013 05:44:41 +0400 Subject: [dba-VB] =?utf-8?q?CodeFirst=2C_DataBinding_and_audit_trailing_de?= =?utf-8?q?leted_items_on_client_side?= In-Reply-To: <1366162766.215615498@f53.mail.ru> References: <1366024971.329024624@f25.mail.ru> <1366162766.215615498@f53.mail.ru> Message-ID: <1366163081.868137164@f372.mail.ru> Sample code Part II - it has to be "glued" with Part I: // traces individual editions and deletions private void _entityBindingSource_ListChanged(object sender, ListChangedEventArgs e) { if (_loadInProgress) return; auditTrailModelChanges(ref _auditTrailItems); } // traces individual deletions private void _entityDataGridView_RowsRemoved(object sender, DataGridViewRowsRemovedEventArgs e) { if (_loadInProgress) return; auditTrailModelChanges(ref _auditTrailItems); } private string getKeyValue(T item) { return (string)_context.Entry(item).Property(_altKeyFieldName).CurrentValue; } private int getIDValue(T item) { return (int)_context.Entry(item).Property(_idFieldName).CurrentValue; } void IDisposable.Dispose() { Dispose(true); GC.SuppressFinalize(this); } protected virtual void Dispose(bool disposing) { if (disposing) { if (_entityBindingSource != null) _entityBindingSource.ListChanged -= new ListChangedEventHandler(_entityBindingSource_ListChanged); if (_entityDataGridView != null) _entityDataGridView.RowsRemoved -= new DataGridViewRowsRemovedEventHandler(_entityDataGridView_RowsRemoved); } } // saves changes and returns actual set of data changes public Dictionary SaveChanges() { var batchAuditTrailItems = new Dictionary(); auditTrailModelChanges(ref batchAuditTrailItems); _context.SaveChanges(); return batchAuditTrailItems; } //+ debug/test #if DEBUG public IEnumerable GetAuditTrailItemsTestReportString(Dictionary auditTrailItems) { foreach (var textLine in this.GetAuditTrailItemsTestReport(auditTrailItems)) { yield return textLine + System.Environment.NewLine; } } public List GetAuditTrailItemsTestReport(Dictionary auditTrailItems) { if (auditTrailItems == null) return new List(); List report = new List(); foreach (var auditTrailItem in auditTrailItems.Values) { report.Add( string.Format( " {0}: ID = '{1}', Name = '{2}'\n", auditTrailItem.ItemState.ToString(), getIDValue(auditTrailItem.Item), getKeyValue(auditTrailItem.Item))); } return report; } #endif //- debug/test } } ?????, 17 ?????? 2013, 5:39 +04:00 ?? Salakhetdinov Shamil : >Hi Scott -- > >Thank you for your sample. I have prepared mine, which I will post here in several subsequent posts as one posting limit is 20KB. > >By "individual changes" I mean *all* the data changes happened between data load and data saving, And I wanted to "capture" that individual data changes as soon as they happen not before .SaveChanges() call. <<< skipped >>> > From mcp2004 at mail.ru Tue Apr 16 21:12:15 2013 From: mcp2004 at mail.ru (=?UTF-8?B?U2FsYWtoZXRkaW5vdiBTaGFtaWw=?=) Date: Wed, 17 Apr 2013 06:12:15 +0400 Subject: [dba-VB] =?utf-8?q?CodeFirst=2C_DataBinding_and_audit_trailing_de?= =?utf-8?q?leted_items_on_client_side?= In-Reply-To: <1366162766.215615498@f53.mail.ru> References: <1366024971.329024624@f25.mail.ru> <1366162766.215615498@f53.mail.ru> Message-ID: <1366164735.298584497@f146.mail.ru> Here is how the code posted in my two previous postings can be used with a test WinForm with one gridview bound to a DbSet via BidingSource, three test buttons and one test textox. Previously posted and the following code is not used in production nor I plan to use it in production environment soon - this coding is more for learning purposes of CodeFirst approach ( http://www.amazon.com/Programming-Entity-Framework-Code-First/dp/1449312942/ref=sr_1_2?ie=UTF8&qid=1366164644&sr=8-2&keywords=DbContext ) and DbContext ( http://www.amazon.com/Programming-Entity-Framework-Julia-Lerman/dp/1449312969/ref=sr_1_1?ie=UTF8&qid=1366164644&sr=8-1&keywords=DbContext ). using System; using System.Windows.Forms;namespace TestWindowsFormsApplication1 { public partial class TestForm : Form { public TestForm() { InitializeComponent(); } private GenericEntityGridViewHandler _handler; private void Form1_Load(object sender, EventArgs e) { string sql = "select * from MyTestEntity?order by [Name] ASC"; _handler = new GenericEntityGridViewHandler(myTestEntityDataGridView, myTestEntityBindingSource, sql); _handler.LoadData(); } private void cmdSaveAll_Click(object sender, EventArgs e) { var report = _handler.SaveChanges(); auditTrailReportTextBox.Text = ""; foreach (var textLine in _handler.GetAuditTrailItemsTestReportString(report)) { auditTrailReportTextBox.Text += textLine; } } private void cmdReloadData_Click(object sender, EventArgs e) { _handler.LoadData(); } private void cmdReportCurrentAuditTrail_Click(object sender, EventArgs e) { auditTrailReportTextBox.Text = ""; foreach (var textLine in _handler.GetAuditTrailItemsTestReportString(_handler.AuditTrailItems ) ) { auditTrailReportTextBox.Text += textLine; } } } } Thank you. -- Shamil ?????, 17 ?????? 2013, 5:39 +04:00 ?? Salakhetdinov Shamil : >Hi Scott -- > >Thank you for your sample. I have prepared mine, which I will post here in several subsequent posts as one posting limit is 20KB. > >By "individual changes" I mean *all* the data changes happened between data load and data saving, And I wanted to "capture" that individual data changes as soon as they happen not before .SaveChanges() call. <<< skipped >>> > From dbdoug at gmail.com Tue Apr 16 22:02:16 2013 From: dbdoug at gmail.com (Doug Steele) Date: Tue, 16 Apr 2013 20:02:16 -0700 Subject: [dba-VB] CodeFirst, DataBinding and audit trailing deleted items on client side In-Reply-To: <1366164735.298584497@f146.mail.ru> References: <1366024971.329024624@f25.mail.ru> <1366162766.215615498@f53.mail.ru> <1366164735.298584497@f146.mail.ru> Message-ID: Thank you for posting this, Shamil! Doug On Tue, Apr 16, 2013 at 7:12 PM, Salakhetdinov Shamil wrote: > Here is how the code posted in my two previous postings can be used with > a test WinForm with one gridview bound to a DbSet< MyTestEntity> via > BidingSource, three test buttons and one test textox. Previously posted and > the following code is not used in production nor I plan to use it in > production environment soon - this coding is more for learning purposes of > CodeFirst approach ( > http://www.amazon.com/Programming-Entity-Framework-Code-First/dp/1449312942/ref=sr_1_2?ie=UTF8&qid=1366164644&sr=8-2&keywords=DbContext) and DbContext ( > http://www.amazon.com/Programming-Entity-Framework-Julia-Lerman/dp/1449312969/ref=sr_1_1?ie=UTF8&qid=1366164644&sr=8-1&keywords=DbContext). > > using System; > using System.Windows.Forms;namespace TestWindowsFormsApplication1 > { > public partial class TestForm : Form > { > public TestForm() > { > InitializeComponent(); > } > private GenericEntityGridViewHandler > _handler; > private void Form1_Load(object sender, EventArgs e) > { > string sql = "select * from MyTestEntity order by [Name] ASC"; > _handler = new GenericEntityGridViewHandler MyTestEntity>(myTestEntityDataGridView, myTestEntityBindingSource, sql); > _handler.LoadData(); > } > private void cmdSaveAll_Click(object sender, EventArgs e) > { > var report = _handler.SaveChanges(); > auditTrailReportTextBox.Text = ""; > foreach (var textLine in > _handler.GetAuditTrailItemsTestReportString(report)) > { > auditTrailReportTextBox.Text += textLine; > } > } > private void cmdReloadData_Click(object sender, EventArgs e) > { > _handler.LoadData(); > } > private void cmdReportCurrentAuditTrail_Click(object sender, EventArgs e) > { > auditTrailReportTextBox.Text = ""; > foreach (var textLine in > _handler.GetAuditTrailItemsTestReportString(_handler.AuditTrailItems ) ) > { > auditTrailReportTextBox.Text += textLine; > } > } > } > } Thank you. > > -- Shamil > > > ?????, 17 ?????? 2013, 5:39 +04:00 ?? Salakhetdinov Shamil < > mcp2004 at mail.ru>: > >Hi Scott -- > > > >Thank you for your sample. I have prepared mine, which I will post here > in several subsequent posts as one posting limit is 20KB. > > > >By "individual changes" I mean *all* the data changes happened between > data load and data saving, And I wanted to "capture" that individual data > changes as soon as they happen not before .SaveChanges() call. > <<< skipped >>> > > > _______________________________________________ > dba-VB mailing list > dba-VB at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-vb > http://www.databaseadvisors.com > > From mcp2004 at mail.ru Tue Apr 16 22:34:48 2013 From: mcp2004 at mail.ru (mcp2004 at mail.ru) Date: Tue, 16 Apr 2013 23:34:48 -0400 (EDT) Subject: [dba-VB] Registration Notification Message-ID: <24521468.51628.1366169688397.JavaMail.root@IronPortIEAPR02.MassMutual.com> A Message from the Secure Mail Center -------------------------------------------------- mcp2004 at mail.ru has sent you a message using the Secure Mail Center. Before you can read this message you must first register. To register with the Secure Mail Center, Click here or go to https://securemailmm.com/websafe/register?uuid=6dd0a2673b190f167f000001dc031642. Thank you for trusting us with your financial needs. If you have concerns about the validity of this message, contact the sender directly. Thank you, Secure Mail Center Customer Support --------------------------------------------------- To know more about the Secure Mail Center, Click here, https://securemailmm.com/websafe/branding/Secure_Email_Quick_Guide.html From stuart at lexacorp.com.pg Tue Apr 16 23:25:26 2013 From: stuart at lexacorp.com.pg (Stuart McLachlan) Date: Wed, 17 Apr 2013 14:25:26 +1000 Subject: [dba-VB] Registration Notification In-Reply-To: <24521468.51628.1366169688397.JavaMail.root@IronPortIEAPR02.MassMutual.com> References: <24521468.51628.1366169688397.JavaMail.root@IronPortIEAPR02.MassMutual.com> Message-ID: <516E2436.25474.19E80323@stuart.lexacorp.com.pg> SPAM! Moderators. Please permanently block mail routed through MassMutual.com Congrats Shamil, you are the first member of the DBA-Lists to get into my permanent kill file. -- Stuart On 16 Apr 2013 at 23:34, mcp2004 at mail.ru wrote: > A Message from the Secure Mail Center > -------------------------------------------------- > > mcp2004 at mail.ru has sent you a message using the Secure > Mail Center. > > Before you can read this message you must first > register. > > To register with the Secure Mail Center, > Click here or go to https://securemailmm.com/websafe/register?uuid=6dd0a2673b190f167f000001dc031642. > > > Thank you for trusting us with your financial needs. > If you have concerns about the validity of this > message, contact the sender directly. > > Thank you, > Secure Mail Center Customer Support > > --------------------------------------------------- > To know more about the Secure Mail Center, > Click here, https://securemailmm.com/websafe/branding/Secure_Email_Quick_Guide.html > _______________________________________________ > dba-VB mailing list > dba-VB at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-vb > http://www.databaseadvisors.com > > From mcp2004 at mail.ru Wed Apr 17 03:20:28 2013 From: mcp2004 at mail.ru (=?UTF-8?B?U2FsYWtoZXRkaW5vdiBTaGFtaWw=?=) Date: Wed, 17 Apr 2013 12:20:28 +0400 Subject: [dba-VB] =?utf-8?q?Registration_Notification?= In-Reply-To: <516E2436.25474.19E80323@stuart.lexacorp.com.pg> References: <24521468.51628.1366169688397.JavaMail.root@IronPortIEAPR02.MassMutual.com> <516E2436.25474.19E80323@stuart.lexacorp.com.pg> Message-ID: <1366186828.955347612@f395.i.mail.ru> Hi Stuart -- I see similar message in Access-D coming mimiced not my but another Access-D member address - do you see it? Thank you. -- Shamil ?????, 17 ?????? 2013, 14:25 +10:00 ?? "Stuart McLachlan" : >SPAM! > >Moderators. Please permanently block mail routed through MassMutual.com > >Congrats Shamil, you are the first member of the DBA-Lists to get into my permanent kill file. > > >-- >Stuart > > >On 16 Apr 2013 at 23:34, mcp2004 at mail.ru wrote: > >> A Message from the Secure Mail Center >> -------------------------------------------------- >> >> mcp2004 at mail.ru has sent you a message using the Secure >> Mail Center. >> >> Before you can read this message you must first >> register. >> >> To register with the Secure Mail Center, >> Click here or go to <<< SPAM LINK dropped >>> >> >> >> Thank you for trusting us with your financial needs. >> If you have concerns about the validity of this >> message, contact the sender directly. >> >> Thank you, >> Secure Mail Center Customer Support > From mcp2004 at mail.ru Wed Apr 17 06:42:02 2013 From: mcp2004 at mail.ru (=?UTF-8?B?U2FsYWtoZXRkaW5vdiBTaGFtaWw=?=) Date: Wed, 17 Apr 2013 15:42:02 +0400 Subject: [dba-VB] =?utf-8?q?CodeFirst=2C_DataBinding_and_audit_trailing_de?= =?utf-8?q?leted_items_on_client_side?= References: <1366024971.329024624@f25.mail.ru> <1366164735.298584497@f146.mail.ru> Message-ID: <1366198922.737257762@f208.mail.ru> Hi Doug, My pleasure! I have changed the code slightly - added JSON serializer to audit trailed items: public class AuditTrailItem { public AuditTrailItem(System.Data.EntityState itemState, T item, string itemKey) { this.ItemState = itemState; this.Item = item; this.ItemKey = itemKey; var serializer = new JavaScriptSerializer(); ItemJSON = serializer.Serialize(item);? } public System.Data.EntityState ItemState { get; private set; } public T Item { get; private set; } public string ItemKey { get; private set; } public string ItemJSON { get; private set; } } JSON serialization can be done by using?System.Web.Script.Serialization.JavaScriptSerializer class. It's needed here as the audit trailed item natural key ([Name] field in my test case) can be changed and then the same item will be present more than one time in audit trail?Dictionary. And then last function of the lengthy class I have posted in my prev. postings will become: public List GetAuditTrailItemsTestReport(Dictionary auditTrailItems) { if (auditTrailItems == null) return new List(); List report = new List(); foreach (var auditTrailItem in auditTrailItems.Values) { report.Add( string.Format( " {0}: ID = '{1}', Name = '{2}', JSON = '{3}'\n", auditTrailItem.ItemState.ToString(), getIDValue(auditTrailItem.Item), getKeyValue(auditTrailItem.Item), auditTrailItem.ItemJSON)? ); } return report; } ?Thank you. -- Shamil? ???????, 16 ?????? 2013, 20:02 -07:00 ?? Doug Steele : >Thank you for posting this, Shamil! > >Doug > > >On Tue, Apr 16, 2013 at 7:12 PM, Salakhetdinov Shamil < mcp2004 at mail.ru > wrote: >>?Here is how the code posted in my two previous postings can be used with a test WinForm with one gridview bound to a DbSet via BidingSource, three test buttons and one test textox. Previously posted and the following code is not used in production nor I plan to use it in production environment soon - this coding is more for learning purposes of CodeFirst approach ( http://www.amazon.com/Programming-Entity-Framework-Code-First/dp/1449312942/ref=sr_1_2?ie=UTF8&qid=1366164644&sr=8-2&keywords=DbContext ) and DbContext ( http://www.amazon.com/Programming-Entity-Framework-Julia-Lerman/dp/1449312969/ref=sr_1_1?ie=UTF8&qid=1366164644&sr=8-1&keywords=DbContext ). >> >>using System; >>using System.Windows.Forms;namespace TestWindowsFormsApplication1 >>{ >>public partial class TestForm : Form >>{ <<< skipped >>> > >>