Top DevX Stories
Creating Custom Export Filters for StarOffice with XSLT
WPF Wonders: Using DataTemplates
Crystal Reports Family Offers Options for Developers
Avaya Aura Session Manager video
Avaya Aura Overview video
Search the forums:

Go Back   DevX.com Forums > DevX Developer Forums > .NET

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 11-06-2009, 12:27 PM
joewmaki joewmaki is offline
Registered User
 
Join Date: May 2004
Location: Duluth MN
Posts: 311
Entity Value Comparison

I need to reference the original values of an entity before doing a SaveChanges(). Is the value in the store available and what is the syntax to access it?

Example: I have an Employee entity and change the Hours of the employee. How can I determine, before I implement the SaveChanges() that Hours has been modified?
__________________

...joe
Reply With Quote
  #2  
Old 11-06-2009, 03:02 PM
joewmaki joewmaki is offline
Registered User
 
Join Date: May 2004
Location: Duluth MN
Posts: 311
Figured out a solution:

Code:
Sub CheckModifiedValues(ByVal Context As ObjectContext)
        Try
            'Get all objects modified
            Dim Changes As IEnumerable(Of ObjectStateEntry) = Context.ObjectStateManager.GetObjectStateEntries(EntityState.Modified)
            If Changes.Count > 0 Then
                'Loop through changed objects
                For Each Obj In Changes
                    'get the properties modified for the object
                    Dim ModifiedProperties As IEnumerable(Of String) = Obj.GetModifiedProperties
                    If ModifiedProperties.Count > 0 Then
                        For Each prop As String In ModifiedProperties
                            'these will error if you pass through a property that was not modified - thus the GetModifiedProperties
                            Dim strOrg As String = Obj.OriginalValues(prop).ToString
                            Dim strMod As String = Obj.CurrentValues(prop).ToString
                            MessageBox.Show("Current " & prop & ": " & strMod & " Original " & prop & ": " & strOrg)
                        Next
                    End If
                Next
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub
__________________

...joe
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
a simple question about design patterns mkamoski .NET 1 08-13-2009 08:41 PM
Comparison methods ericelysia1 Java 34 05-15-2005 07:39 PM
How to call the ejbCreate() method of an entity bean from WITHIN the entity bean Jared Dinerstein Java 0 09-28-2002 07:23 PM
entity references in XSD definitions? unknown XML 0 04-02-2002 12:15 PM
Wanted: Entity EJBs With Configurable Attributes Jim Bowman Java 1 05-10-2000 06:20 PM


All times are GMT -4. The time now is 02:25 AM.


Sponsored Links



Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.