Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Can someone please advise me how I can get PropertyChanged.Fody to work with WPF databinding and EF 6.0 Database first?
I am not using MVVM.
I have an EF generated class called "Test" as follows....

C#
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated from a template.
//
//     Manual changes to this file may cause unexpected behavior in your application.
//     Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace RMS_EF6
{
    using System;
    using System.Collections.ObjectModel;
    
    public partial class Test
    {
        public int TestIdentityKey { get; set; }
        public Nullable<int> TestNumber1 { get; set; }
        public Nullable<int> TestNumber2 { get; set; }
        public string TestDescription1 { get; set; }
    }
}

I have created the following PropertyChanged.Fody class as follows....

C#
using PropertyChanged;

    [AddINotifyPropertyChangedInterfaceAttribute]
    public partial class Test
    {
        private void ArithmeticTest()
        {
            TestNumber1 = 2 * TestNumber2;
            Console.WriteLine($"TestNumber1 = {TestNumber1} \n + TestNumber2 = {TestNumber2}");
        }
    }

I can update the individual fields in the database with manual input through the WPF GUI OK using WPF databinding.

However, I want to execute methods like ArithmeticTest() in the code-behind when the users enter data through the GUI.  Eg when the value of TestNumber2 changes as a result of user input.
Can anyone please tell me what I need to add to my code to make this happen?


What I have tried:

I have been experimenting with the code above and have gotten nowhere.
Posted
Updated 2-May-18 21:55pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900