Last post Feb 06, 2009 01:33 PM by ricka6
Jan 25, 2009 10:23 AM|m@rco|LINK
Can someone tell me what the AutoLoadForeignKeys property is for?
I thought that when I set AutoLoadForeignKeys to false, the foreign key fields didn't show up....
Jan 25, 2009 12:51 PM|davidebb|LINK
AutoLoadForeignKeys only applies if you're using Linq To Sql. When set to true, it causes the related entities to be loaded in the initial query. e.g. The Category and Supplier get loaded along with the Product (via a SQL JOIN). But note that when you
set it to false, Linq To Sql will still load the related objects on demand (e.g. at the time Product.Category is accessed). So you may not notice teh diffence unless you look at the SQL queries being issued. Basically, it's an optimization.
That's why it doesn't really have any effect on whether the FK fields show up.
Feb 06, 2009 01:19 PM|samw|LINK
>> AutoLoadForeignKeys only applies if you're using Linq To Sql.
Is there an equivilant for L2E?
Or, more generally, here is my question: I am using Northwind and L2E. I want to display product category name in a products gridview on a dynamic data page. How do I accomplish that?
Feb 06, 2009 01:33 PM|ricka6|LINK
AutoLoadForeignKeys is just an optimization - it has zero impact on what is displayed. And it's an optimization for L2S only.
Use the DisplayColumn attribute in the category entity.