LinqDatasource Where 字段上的子句属于通过外键链接的表

发布于 2024-12-01 05:48:47 字数 861 浏览 4 评论 0原文

我有 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

计㈡愣 2024-12-08 05:48:47

As 完成的别名发生在 Where 完成过滤之后。尝试将您的 Where 更改为 Owner.Owner_Name != null (我还没有尝试过),或者您可能不需要 Owner。

The aliasing done by As happens after the filtering done by Where. Try changing your Where to Owner.Owner_Name != null (I haven't tried this), or perhaps you don't need the Owner.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文