【问题标题】:What is "it" in EntityDataSource's select property?EntityDataSource 的 select 属性中的“它”是什么?
【发布时间】:2011-01-19 06:34:55
【问题描述】:

例如:

<asp:EntityDataSource ID="EntityDataSource2" runat="server" 
            ConnectionString="name=AdventureWorksEntities" 
            DefaultContainerName="AdventureWorksEntities"  
            EnableUpdate="True" EntitySetName="Employee" 
            Select="" Where="it.EmployeeID = @selEmpID">
            <WhereParameters>
            <asp:ControlParameter ControlID="GridView1" Name="selEmpID" Type="Int32" PropertyName="SelectedValue" />
            </WhereParameters>
</asp:EntityDataSource> 

“它”是由 EntityDataSource 生成的吗? "it" 是 Employee 的实体别名,但如何定义呢?

例如,如果我通过以下属性包含其他实体:

Include="Users,Permissions"

如何为不同的实体定义不同的别名 例如:

emp = 员工 usr = 用户 perm = 权限

【问题讨论】:

    标签: ado.net-entity-data-model


    【解决方案1】:

    “它”是“控制变量”。您可以使用 ObjectQuery 的 Name 属性更改它。

    ObjectQuery 是您得到的,例如从您的 ObjectContext 类中得到的,例如 context.Products 或 context.Customers。

    var query = context.Products;
    query.Name = "products";  // changes "it" to "products"
    

    【讨论】:

    • 你能引用这方面的文档吗?您的回答很有帮助,但我想知道我的 MSDN 研究工作出了什么问题...
    • @pseudocoder - 我从Julia Lehrman's EF book 了解到“它”。 Here it is on MSDN.
    • 我听说过这本书的好消息,非常感谢您的参考!
    • 没问题。如果您正在考虑购买它,我建议您等到她为新的(ish)代码优先工作流程更新它。
    猜你喜欢
    • 2017-11-18
    • 1970-01-01
    • 1970-01-01
    • 2015-08-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多