翻译<>和ExecuteStoreQuery<>映射没有工作? [英] Translate<> and ExecuteStoreQuery<> mapping did'nt work ?

查看:79
本文介绍了翻译<>和ExecuteStoreQuery<>映射没有工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用EFCTP4 我尝试使用 翻译<>加载实体或&NBSP; ExecuteStoreQuery<> ,但ObjectContext引发错误,如"找不到字段xx"

Using EFCTP4 I tried to load entities using Translate<> or ExecuteStoreQuery<> , but ObjectContext raise error like "cannot find field xx"

我使用下一个环境:

表客户(  cu_ID uniqueidentifier NOT NULL, cu_Name varchar(50)NOT NULL,  CONSTRAINT [PK_ID] PRIMARY KEY CLUSTERED (cu_ID ASC) )

table Customer (  cu_ID uniqueidentifier NOT NULL, cu_Name varchar(50) NOT NULL, CONSTRAINT [PK_ID] PRIMARY KEY CLUSTERED (cu_ID ASC) )

实体:公共类客户{public Guid ID {get; set; } public  string Name {get; set;}}

Entity: public class Customer { public Guid ID {get;set;} public  string Name{get;set;} }

映射: 


 builder.Entity<Customer>().HasKey(x => new {x.ID}).MapHierarchy(x=>new{cu_ID=x.ID,cu_Name=x.Name}).ToTable("Customer");

推荐答案

你好Alex,

Hi Alex,

使用原始SQL绕过EF的映射部分,所以你需要对列进行别名以匹配属性名称。

Using raw SQL does bypass the mapping portion of EF so you do need to alias the columns to match the property names.

感谢您的反馈,我们将来会考虑添加此选项,请随意在我们的客户反馈网站上创建建议;

https://data.uservoice。 com / forums / 72025-ado-net-entity-framework-ef-feature-suggestions

Thank you for the feedback though and we will look at adding this option in the future, feel free to create a suggestion on our customer feedback site; https://data.uservoice.com/forums/72025-ado-net-entity-framework-ef-feature-suggestions

~Rowan


这篇关于翻译&LT;&GT;和ExecuteStoreQuery&lt;&gt;映射没有工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆