8,734
社区成员
发帖
与我相关
我的任务
分享
public App()
{
InitializeComponent();
// Create a WebContext and add it to the ApplicationLifetimeObjects
// collection. This will then be available as WebContext.Current.
WebContext webContext = new WebContext();
webContext.Authentication = new FormsAuthentication();
//webContext.Authentication = new WindowsAuthentication();
this.ApplicationLifetimeObjects.Add(webContext);
LyDomainContext ly = new LyDomainContext();
ly.Load(ly.GetVw_client_allQuery());
LyClientAll.DB = ly.vw_client_alls; //这里报错
}
vw_client_all obj = LyClientAll.DB.FirstOrDefault(n => n.sys_id == (string)value);
if(obj != null)
{
return obj.简称 ;
}
else
{
return "some value" ;
}
<sdk:DataGridTextColumn x:Name="shipper" Binding="{Binding Path=shipper, Converter={StaticResource LyGetClientName }}" Header="发货人" Width="Auto" />
<sdk:DataGridTextColumn x:Name="consignee" Binding="{Binding Path=consignee, Converter={StaticResource LyGetClientName }}" Header="收货人" Width="Auto" />
public class LyClientAll
{
public static IEnumerable<vw_client_all> DB { get; set; }
//public static ObservableCollection<vw_client_all> DB1 { get; set; }
}
public class LyGetClientName : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null) return null;
string ClientName = LyClientAll.DB.Where(n => n.sys_id == (string)value).Select(n => n.简称).FirstOrDefault();
return ClientName;
}
#region IValueConverter 成员
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
#endregion
}
LyDomainContext ly = new LyDomainContext();
ly.Load(ly.GetVw_client_allQuery());
LyGetClientAll.DB = ly.vw_client_alls;