C# 使用automapper system.strin映射到字符串异常

C# 使用automapper system.strin映射到字符串异常,c#,.net,asp.net-mvc,automapper,C#,.net,Asp.net Mvc,Automapper,我有两门课 头等舱是 public class Client : BaseEntity { public Client() { ReportingPeriods = new List<ReportingPeriod>(); UserAccesses = new List<UserClientAccess>(); GraphColours = new List<Graph

我有两门课

头等舱是

 public class Client : BaseEntity
    {
        public Client()
            {
        ReportingPeriods = new List<ReportingPeriod>();
        UserAccesses = new List<UserClientAccess>();
        GraphColours = new List<GraphColour>();
        RangeColours = new List<RangeColour>();
        Properties = new List<PropertyMaster>();
        PropertyCustomFilterHeaderMasters = new List<PropertyCustomFilterHeaderMaster>();
        InterestCustomFilterHeaderMasters = new List<InterestCustomFilterHeaderMaster>();
        Comments = new List<Comment>();
        CustomDashboards = new List<CustomDashboard>();
        Bookmarks = new List<Bookmark>();
    }

    public string Name { get; set; }

    [IgnoreComparing]
    public byte[] Logo { get; set; }

    [Display(Name = "Logo Name")]
    public string LogoName { get; set; }

    public ClientStatus Status { get; set; }

    [IgnoreComparing]
    public virtual ICollection<ReportingPeriod> ReportingPeriods { get; set; }
    [IgnoreComparing]
    public virtual ICollection<UserClientAccess> UserAccesses { get; set; }

    public virtual ICollection<PropertyCustomFilterHeaderMaster> PropertyCustomFilterHeaderMasters { get; set; }
    [IgnoreComparing]
    public virtual ICollection<InterestCustomFilterHeaderMaster> InterestCustomFilterHeaderMasters { get; set; }
    [IgnoreComparing]
    public virtual ICollection<Comment> Comments { get; set; }
}
我可以用这种方式用automapper映射这两个类吗

cfg.CreateMap<Client, ClientDto>();
cfg.CreateMap();
我正在尝试创建映射,一切正常,但应用程序抛出异常

{“LINQ to Entities无法识别方法'System.String ToString()'方法,并且无法将此方法转换为存储表达式。”}

这是linq查询

public async Task<PagedResultOutput<ClientDto>> GetClients(GetClientsInput input) 
{ 
    var clients = Queryable().AsNoTracking(); 
    var totalCount = await clients.CountAsync(); 
    clients = clients.OrderBy(input.Sorting)
                     .Skip(input.SkipCount)
                     .Take(in‌​put.MaxResultCount); 
     return new PagedResultOutput<ClientDto>(totalCount, await clients.ProjectToListAsync<ClientDto>(_mapperConfiguration))‌​; 
}
公共异步任务GetClient(GetClientsInput输入)
{ 
var clients=Queryable().AsNoTracking();
var totalCount=await clients.CountAsync();
clients=clients.OrderBy(输入.排序)
.Skip(输入.SkipCount)
接受‌​put.MaxResultCount);
返回新的PagedResultOutput(totalCount,等待客户端。ProjectToListSync(\u mapperConfiguration))‌​; 
}

我认为异常与您有关LINQ查询未映射我的LINQ查询是公共异步任务GetClient(GetClientsInput input){var clients=Queryable().AsNoTracking();var totalCount=Wait clients.CountAsync();clients=clients.OrderBy(input.Sorting).Skip(input.SkipCount).获取(input.MaxResultCount);返回新的PagedResultOutput(totalCount,等待客户端.ProjectToListSync(_-mapperConfiguration));},而不是等待客户端.ProjectToListSync(_-mapperConfiguration))‌​;, 如果简化为客户机,会发生什么?选择(c=>c.Name)?按照我读取映射的方式,只有Name属性会被映射,但dto和实体都继承了其他类。。。也许你可以切掉不相关的部分,只发布仍然触发错误的最小值?我在
客户端
中没有看到
AreaUnit
Currency
。您的代码是否完整?我认为异常与您有关LINQ查询未映射我的LINQ查询是公共异步任务GetClient(GetClientsInput input){var clients=Queryable().AsNoTracking();var totalCount=await clients.CountAsync();clients=clients.OrderBy(input.Sorting).跳过(input.SkipCount).Take(input.MaxResultCount);返回新的PagedResultOutput(totalCount,等待客户端.ProjectToListSync(_-mapperConfiguration));},而不是等待客户端.ProjectToListSync(_-mapperConfiguration))‌​;, 如果简化为客户机,会发生什么?选择(c=>c.Name)?按照我读取映射的方式,只有Name属性会被映射,但dto和实体都继承了其他类。。。也许你可以切掉不相关的部分,只发布仍然触发错误的最小值?我在
客户端
中没有看到
AreaUnit
Currency
。你的代码完整吗?
public async Task<PagedResultOutput<ClientDto>> GetClients(GetClientsInput input) 
{ 
    var clients = Queryable().AsNoTracking(); 
    var totalCount = await clients.CountAsync(); 
    clients = clients.OrderBy(input.Sorting)
                     .Skip(input.SkipCount)
                     .Take(in‌​put.MaxResultCount); 
     return new PagedResultOutput<ClientDto>(totalCount, await clients.ProjectToListAsync<ClientDto>(_mapperConfiguration))‌​; 
}