C# Gridlookupedit实体框架
如何正确填写gridlookupedit?C# Gridlookupedit实体框架,c#,entity-framework,linq,devexpress,gridlookupedit,C#,Entity Framework,Linq,Devexpress,Gridlookupedit,如何正确填写gridlookupedit? 我找不到错误 方法fill gridlookupedit public void CargaGLEVerdadero() { pcbjEntidades contexto = new pcbjEntidades(); IList consultaModeloInsumosVerdadera = (from ModeloInsumoes in contexto.ModeloInsumoes
我找不到错误 方法fill gridlookupedit
public void CargaGLEVerdadero()
{
pcbjEntidades contexto = new pcbjEntidades();
IList consultaModeloInsumosVerdadera = (from ModeloInsumoes in contexto.ModeloInsumoes
where
ModeloInsumoes.Activo == true
select new
{
ModeloInsumoes.NombreModeloInsumo
}).ToList();
gleNombreModelo.Properties.DataSource = new BindingSource(consultaModeloInsumosVerdadera, "");
}
形式建构
public frmAgregarMarca()
{
InitializeComponent();
CargaGLEVerdadero();
}
此问题与GridLookup没有直接关系,而是与EF/Winforms互操作相关 由于您使用的是DevXPress,因此可以使用。此功能可用于threir套件中的任何数据感知控件,它知道如何正确执行操作,并可为您完成所有工作:
// This line of code is generated by Data Source Configuration Wizard
// Instantiate a new DBContext
WindowsFormsApplication2.CountriesDBEntities dbContext = new WindowsFormsApplication2.CountriesDBEntities();
// Call the Load method to get the data for the given DbSet from the database.
dbContext.Countries.Load();
// This line of code is generated by Data Source Configuration Wizard
gridLookUpEdit1.Properties.DataSource = dbContext.Countries.Local.ToBindingList();
然后您可以自定义向导的输出:
dbContext.Countries.Where(c => c.Capital.StartsWith("A")).Load();
如果看到图片,必须仅用“L222011”填写gridlookupedit