LinqDatasource Where 字段上的子句属于通过外键链接的表
我有 2 个表、电子邮件和所有者,它们通过外键链接。电子邮件有一个列 Owner_FID,它是所有者的 Owner_ID 的 FK。
我有一个用于电子邮件表的 Linq 数据源,我想使用Where 来过滤它 关于 Owner.Owner_Name
Linq 数据源:
<asp:LinqDataSource ID="LinqEmails" runat="server" ContextTypeName="ACGlobalEmail.GlobalEmailDLDataContext" EntityTypeName="" TableName="Emails" EnableUpdate="False" Where="Name != null"
Select="new(Emall_Address,
Owner_FID,Contact_Name,Language,Owner.Owner_Name as Name)">
</asp:LinqDataSource>
我已遵循 MSDN 指南(此处) http://msdn.microsoft.com/en-us/library/bb470363.aspx .. 看起来很简单,但我
在“/”应用程序中得到了服务器错误。
“电子邮件”类型中不存在属性或字段“名称” 描述:执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其在代码中的来源的更多信息。
异常详细信息:System.Web.Query.Dynamic.ParseException:“电子邮件”类型中不存在属性或字段“名称”
I have 2 Tables, Emails and Owners that are linked with a foreign key . Emails has a Column Owner_FID which is a FK to Owner_ID of Owners.
I have a Linq Datasource for the Emails Table and i want to filter it using Where
On the Owner.Owner_Name
Linq Datasource :
<asp:LinqDataSource ID="LinqEmails" runat="server" ContextTypeName="ACGlobalEmail.GlobalEmailDLDataContext" EntityTypeName="" TableName="Emails" EnableUpdate="False" Where="Name != null"
Select="new(Emall_Address,
Owner_FID,Contact_Name,Language,Owner.Owner_Name as Name)">
</asp:LinqDataSource>
i Have Followed MSDN Guidelines here
http://msdn.microsoft.com/en-us/library/bb470363.aspx.. it seems preety simple but i get this instead
Server Error in '/' Application.
No property or field 'Name' exists in type 'Email'
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.Query.Dynamic.ParseException: No property or field 'Name' exists in type 'Email'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
As
完成的别名发生在Where
完成过滤之后。尝试将您的Where
更改为Owner.Owner_Name != null
(我还没有尝试过),或者您可能不需要Owner。
The aliasing done by
As
happens after the filtering done byWhere
. Try changing yourWhere
toOwner.Owner_Name != null
(I haven't tried this), or perhaps you don't need theOwner.