我在实体框架中有以下内容。
表-国家
字段
我只想将选定的字段从这个实体模型映射到我的域类。
我的域模型类是
public class DomainCountry
{
public int Country_ID { get; set; }
public string Dialing_Code { get; set; }
public string ISO_3166_1_Alpha_2 { get; set; }
}以下内容将有效,但不可能插入或更新。为了获得插入或更新,我们需要使用ObjectSet<>,,但在我的情况下它不支持。
IQueryable<DomainCountry> countries =
context.Countries.Select(
c =>
new DomainCountry
{
Country_ID = c.Country_Id,
Dialing_Code = c.Dialing_Code,
ISO_3166_1_Alpha_2 = c.ISO_3166_1_Alpha_2
});有什么很好的解决办法吗?伤口真的很棒。
理想情况下,它将是一种代理类,它将支持所有的未来,无论是高度可定制的。
,也就是我们想要向外部世界公开的列。
https://stackoverflow.com/questions/4888002
复制相似问题