这些问题是朋友问我的,我也解决不了。使用 EF6 和 devexpress winform 组件的示例代码。
我正在使用 2 列创建 LookupEditControl。
var cities = context.Cities.Include(p=>p.Country)
.OrderBy(e => e.City.Name)
.OrderBy(e=>e.CountryISOCode)
.ToList();
//countryLookUpEdit.Properties.DataSource = cities;
countryLookUpEdit.Properties.DisplayMember = "Name";
countryLookUpEdit.Properties.ValueMember = "ID";
countryLookUpEdit.Properties.Columns.Clear();
// this column always empty, but Console.WriteLine dumps it
countryLookUpEdit.Properties.Columns.Add(new LookUpColumnInfo("Country.Name", "Country Name", 225));
// this column works
countryLookUpEdit.Properties.Columns.Add(new LookUpColumnInfo("Name", "City Name", 150));
countryLookUpEdit.Properties.DataSource = cities;
查看最后 3 行代码。绑定到“Country.Name”的列始终为空。但另一个有效。
如何将 LookupEditControls 列绑定到业务对象的嵌套属性?