表达式拼接Expression<Func<IEntityMapper, bool>> predicate

        /// <summary>
        /// 重写以筛选出当前上下文的实体映射信息
        /// </summary>
        protected override IEnumerable<IEntityMapper> EntityMappersFilter(IEnumerable<IEntityMapper> entityMappers)
        {
            Type contextType = typeof(TDbContext);
            Expression<Func<IEntityMapper, bool>> predicate = m => m.DbContextType == contextType;
            if (contextType == typeof(DefaultDbContext))
            {
                predicate = predicate.Or(m => m.DbContextType == null);
            }
            return entityMappers.Where(predicate.Compile());
        }
posted @ 2016-06-29 22:48  shiningrise  阅读(1027)  评论(1)    收藏  举报
// 侧边栏目录 // https://blog-static.cnblogs.com/files/douzujun/marvin.nav.my1502.css