Probelm regarding Foreign key code in Business Classes

Probelm regarding Foreign key code in Business Classes

Old forum URL: forums.lhotka.net/forums/t/12157.aspx


mayurimalgave posted on Saturday, September 21, 2013

I have created a Silverlight application using CSLA,without MVVM.

Database Name;EmployeeDb

Tables: 

1] Country {Id,CountryName}

2] State{Id,StateName,CountryId}

I have developed StateEdit.cs,StateGetter.cs,StateExistCommand.cs, StateInfo.cs, StateList.cs. 

My StateList.xaml contains a state datagrid with columns as Id,StateName,CountryName.

I want to display the CountryName of the CountryId from State table on xaml.

To do this,What is the code required in StateInfo.cs & StateList.cs?

Now Datagrid displays CountryId. But how to display its respective CountryName?

JonnyBee replied on Saturday, September 21, 2013

The simple answer is to ad CountryNameas property to StateInfo and load field value when loading data from the database. 

Or if you are concenerned about message size you may load CountruId and CountryName into a KeyValueList and cache the list.
Then make the CountryName property in StateInfo do a lookup in the KeyValueList to return the actual name. 

mayurimalgave replied on Thursday, September 26, 2013

Thank you.. My problem is solved now...

Copyright (c) Marimer LLC