5

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

Cheung
  • 15,293
  • 19
  • 63
  • 93

1 Answers1

4

"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"
anon
  • 4,578
  • 3
  • 35
  • 54
  • Can you cite documentation on this? Your answer is helpful but I'd like to know where my MSDN research efforts went awry... – pseudocoder Aug 06 '12 at 14:57
  • 1
    @pseudocoder - I learned about "it" from [Julia Lehrman's EF book](http://books.google.com/books?id=rtdgHbMeTBMC&pg=PA65&lpg=PA65&dq=it+%22control+variable%22+entity+framework&source=bl&ots=kVskZwHwXA&sig=4tstuqUS5VMlce_hxSj48Rg39OA&hl=en&sa=X&ei=TWYgUMKqC5CO8wS2gYFg&ved=0CEUQ6AEwAA#v=onepage&q=it%20%22control%20variable%22%20entity%20framework&f=false). [Here it is on MSDN](http://msdn.microsoft.com/en-us/library/bb347374.aspx). – anon Aug 07 '12 at 00:55
  • I have heard good things about that book, thanks so much for the reference! – pseudocoder Aug 07 '12 at 13:12
  • 1
    No problem. If you're thinking about buying it, I'd recommend that you wait until she updates it for the new(ish) Code-First workflow. – anon Aug 08 '12 at 00:16