开发者

LINQ to SQL: Updating fields based on foreign key relations during creation of new entities

开发者 https://www.devze.com 2023-03-11 11:14 出处:网络
I\'m using WPF and Xaml I\'m creating a new row into a table. That table has a foreign key relationship. When the user types in the FK field I wan\'t others to update based on the relations. This I d

I'm using WPF and Xaml

I'm creating a new row into a table. That table has a foreign key relationship. When the user types in the FK field I wan't others to update based on the relations. This I do believe happens automatically when I save to DB but I wan't to be able to see it right away.

To give an idea about what I'm trying to do let's assume it's a new person object I'm creating and one field is a Zip code. When a zip code is punched in the city where this zip code belongs should pop up.

In my viewModel I have the Zip code property

 public string ZipCode
    {
        get
        {
            return Model.ZipCode;
        }
        set
        {
            Model.ZipCode = value;
            RaisePropertyChanged("ZipCode");
            RaisePropertyChanged("City");
        }
    }

and the City property

public string City
{
     get
     {
            return Model开发者_如何学C.ZipMasterTable.City;
     }
 }

This works in displaying the correct city for the data already in the table but doesn't update the City field until I commit to database. The user inputting the data however might need to know if he put the right zipcode in and wants to see the City field when inputting and before committing.

Is there any way I can get it updated using Linq to Sql ?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号