System.NotSupportedException:“The entity or complex type 'CSFramework.EF.tb_MyUser' cannot be constructed in a LINQ to Entities query.”


 

图片

 

System.NotSupportedException:“The entity or complex type 'CSFramework.EF.tb_MyUser' cannot be constructed in a LINQ to Entities query.”

某个实体或复杂类型不能在 Linq to entity 中被创建。

 

解决方案

 

图片

 

C# 全选
 public List<tb_MyUser> User_Search(req_Permission_SearchCommon input)
        {
            var q = _dbSys.GetQueryable<tb_MyUser>();
            
            if (!string.IsNullOrEmpty(input.Content))
                q = q.Where(W => W.Account.Contains(input.Content) || W.UserName.Contains(input.Content));
            
            //查询返回动态对象
            var list= q.Select(s => new
            {
                //过滤2个图片字段的数据
                Account = s.Account,
                Address = s.Address,
                CreateTime = s.CreateTime,
                DataSets = s.DataSets,
                DomainId = s.DomainId,
                DomainName = s.DomainName,
                Email = s.Email,
                FlagAdmin = s.FlagAdmin,
                FlagOnline = s.FlagOnline,
                isid = s.isid,
            }).ToList();

            //再转换为具体类型
            return ObjectHelper.Convert<List<tb_MyUser>>(list);

        }
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
C/S框架网
上一篇:EF异步查询报错:The provider for the source 'IQueryable' doesn't implement 'IAsyncQueryProvider'
下一篇:SqlException: 列名 'Discriminator' 无效。
评论列表

发表评论

评论内容
昵称:
关联文章

System.NotSupportedException:“The entity or complex type 'CSFramework.EF.tb_MyUser' cannot be constructed in a LINQ to Entities query.”
The object cannot be deleted because it was not found in the ObjectStateManager
The Database principal owns a schema in the database
C#.NET 实体框架EFEntity Framework)详解
Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the s
SQL:Cannot resolve the collation conflict (字符集冲突)
Entity Framework(EF):测试DbContext.Remove方法,对象状态管理器(Object State Manager)
C#实现SQL查询分析器(C# Visual SQL Query Designer)
Cannot resolve the collation conflict.无法解析等号两边的中文简体和中文繁体字符集
No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'
C# LINQ基础-Linq基本使用方法
How to changing the asp.net development server port?
Entity Framework(EF):DbContextConfiguration属性详解
加密解密tb_DataSet/tb_MyUser表的密码|C/S框架网
C#.NET LINQ入门基础
Entity Framework(EF)测试DbContext.Database.ExecuteSqlCommand方法删除记录
EF异步查询报错:The provider for the source 'IQueryable' doesn't implement 'IAsyncQueryProvider'
FastReport报错:TfrxReportClass cold not be found!
Entity Framework(EF):测试DbContext的Add,Remove相同对象是否执行两次SQL
The server factory could not be located for the given input: Microsoft.Owin.Host.HttpListener