c# - 实体框架在运行时选择子类
问题描述
我的结构如下
public class Mammal
{
public string Name { get; set; }
public string PrintName()
{
return "The name is " + Name;
}
}
public class Dog : Mammal
{
public string Breed { get; set; }
public new string PrintName()
{
return "The name is " + Name + " and i go woof woof";
}
}
在基于属性的运行时,我从实体框架中选择数据,并希望基于变量返回正确的子类型。
如何指定在我的实体框架选择查询中使用哪个子类?
解决方案
推荐阅读
- python - 使用 discord.py 检测和踢 alt
- amazon-web-services - Cloudformation 如果有两个或
- sql - 如何在 SQL Server 数据库中添加与同一服务器上的另一个用户具有相同权限的用户?
- docker - 如何在重新启动或尝试失败后使用 compose 自动重新启动 docker 容器?
- powerbi - 在 Power BI 中隐藏第二个表头
- wpf - 具有绑定值的 ComboBox 项
- c# - 如何遍历列表
子类中的基类? - javascript - filter 函数显示一个空数组
- reactjs - JSX map里面有一个map可以吗?
- ajax - 如何更改“CSRF 令牌不匹配”消息?