using c#, WPF
I try to create IValueConverter
for converting ID from dataBase to another value from another table in same dataBase.
Example: I have one person with ID "1" and in another table NAME "James" for this ID. What I want - to bind ID to some control, and to convert ID in to NAME.
During creating such converter, I got some problem - I can't create converter to non static value. My Question - Are it's possible to create IValueConverter
with non static value?
EDIT:
This is what was done:
public object Convert(object value, Type targetType,
object parameter, System.Globalization.CultureInfo culture)
{
using (var dbContext = new EducationDataBaseEntities())
{
//list for all existing id
List<int> id = null;
//add existing id to list
foreach (var item in dbContext.GradeSet)
{
id.Add(item.GradeId);
}
//check each item and return equialent from db
foreach (int item in id)
{
switch (Int32.Parse((string)parameter))
{
case item:
{
foreach (var items in dbContext.GradeSet)
{
if (item == items.GradeId)
{
return items.Equialent;
}
}
}
}
}
return Binding.DoNothing;
}
}