创建支持IBindingListView的实体列表? [英] Creating a list of entities that supports IBindingListView?

查看:354
本文介绍了创建支持IBindingListView的实体列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在数据存储库中使用以下代码返回一个实体列表。
我想使用winforms绑定源绑定到列表,然后能够支持和过滤绑定源

I use the following code in my data repository to return a list of entities. I want to bind to the list using a winforms bindingsource, and then to be able to support and filter the bindingsource

我目前使用的类似于

mybindingSource.datasource =  repository.GetList(p => p.Id > 0 && p.Archived == false, x => x.Organisation);

然而mybindingSource.SupportsFilter返回false。

however mybindingSource.SupportsFilter returns false.

存储库函数是

public virtual IList<T> GetList(Func<T, bool> where, params Expression<Func<T, object>>[] navigationProperties)
    {
        List<T> list;
        IQueryable<T> dbQuery = ((DbContext)this.context).Set<T>();

        //Apply eager loading
        foreach (var navigationProperty in navigationProperties)
        {
            dbQuery = dbQuery.Include(navigationProperty);
        }

         list = dbQuery.AsNoTracking().Where(where).ToList();

        return list;
    }


推荐答案

您可以使用 BindingListView 由Brian Noyes创作(与Windows Forms 2.0的数据绑定:数据应用程序与.NET

You can use BindingListView created by Brian Noyes(author of "Data Binding with Windows Forms 2.0: Programming Smart Client Data Applications with .NET")

BindingListView .NET库

或实行你自己的如果您有更具体的问题,请问

or implement your own. If you have more specific questions, please ask

这篇关于创建支持IBindingListView的实体列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆