首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >实体框架5: net40

实体框架5: net40
EN

Stack Overflow用户
提问于 2013-02-08 19:04:02
回答 1查看 67关注 0票数 0

我正在用ASP.NET 4.0开发一个web应用程序。我有一个SQL Server2005数据库,我正在使用Entity Framework5连接到它。

代码语言:javascript
复制
public class ArchivioClienti : DbContext
{
    public ArchivioClienti()
        : base("ICAMConnection")
    {
    }

    public DbSet<ClientiProspect> clienti { get; set; }
}        
[Table("pvw_clienti_prospect")]
public class ClientiProspect
{
    [Key]
    public string tipologia { get; set; } 
    public string cod_ppro { get; set; }
    public string rag_soc { get; set; }
    public string indirizzo { get; set; }
    public string cap { get; set; }
    public string citta { get; set; }
    public string prov { get; set; }
    public string nazione { get; set; }
    public string telefono { get; set; }
    public string fax { get; set; }
    public string part_iva { get; set; }
    public string cod_fisc { get; set; }
    public string note { get; set; }
    public string e_mail { get; set; }
    public string cod_ppro_anag { get; set; }
    public string cod_vage { get; set; }
    public string cod_visp { get; set; }
    public string fonte { get; set; }
    public string cod_vzon { get; set; }
    public decimal perc_provv { get; set; }
    public string flag_stato { get; set; }
    public string cod_anag { get; set; }
    public string gg_chiusura { get; set; }
    public DateTime? data_ins { get; set; }
    public string cod_canale { get; set; }

}

我正在尝试从一个表中获取数据。这不是一个真正的表,而仅仅是一个视图。当我使用LINQ加载查询时,

代码语言:javascript
复制
var result = from u in dbClienti.clienti
             select u;

return result.ToList()

我收到了正确数量的结果(与我在SQL Server Management studio中使用相同的查询收到的结果相同),但字段错误:第一个重复多次,第二个相同,依此类推。

为什么它会以这种方式工作?实体框架和数据库视图有什么问题吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-02-08 19:24:19

我假设您的视图配置正确,并且在实体框架之外执行时返回正确的结果?

在Entity Framework中使用视图而不是表是没有问题的。我会运行SQL Profiler,看看E.F在执行查询时在做什么。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14771138

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档