【发布时间】:2019-02-11 22:24:06
【问题描述】:
我正在开发一个使用 Entity Framework Cor 2.1 和 Aspnet Core Web API 的项目。
我有以下值对象
public class Email
{
private string _value;
private Email(string value) => _value = value;
public static Email Create(string email)
{
//... code hidden for clarity
return new Email(email);
}
// I have overridden equality operators to check equality by the _value property
// and also ToString to return _value
}
我将此值对象配置为 Person 实体中的自有类型。
public class Person
{
//... code hidden for clarity
public virtual Email Email {get; private set;}
}
当我用say查询数据库时
_context.People.Where(person => person.Email == Email.Create("example@example.com");
我在控制台上收到以下警告。
The LINQ expression 'where ([person.Email] == __email_0)' could not be translated and will be evaluated locally.
我的Person表中只有几条记录,但是记录多了会影响性能吗?是否有解决方法。
【问题讨论】:
标签: entity-framework-core domain-driven-design ef-core-2.1 owned-types