Search code examples
ado.net-entity-data-model

What is "it" in EntityDataSource's select property?


For example :

<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> 

Is the "it" generate by EntityDataSource? The "it" is the entity alias of Employee, but how can i define that?

For exmaple, if i include other entity by property below :

Include="Users,Permissions"

How to define different alias to different entity e.g.:

emp = Employee usr = Users perm = Permissions


Solution

  • "it" is the "Control Variable." You can change it using ObjectQuery's Name property.

    ObjectQuery is what you get, for example out of your ObjectContext class, such as context.Products or context.Customers.

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