I just upgraded my runtime libraries to the latest version, and I started getting a NullReferenceException. I'm using VS2005, ASP.NET 2.0, SQL Server 2005, and Adapter.
Here's the code that generates the exception:
<asp:TemplateField HeaderText="Carrier">
<ItemTemplate>
<%# ((ApplicationEntity)Container.DataItem).Carrier.Name %>
</ItemTemplate>
</asp:TemplateField>
I'm assuming that a record has a null CarrierEntity, and thus the error. It's not that surprising to me that this is happening, except that this worked just fine before I upgraded. I went from version 2.0.0.60911 to version 2.0.0.61205 of the ORMSupportClasses. I am using a prefetch to load the related entity. I loaded the page once, and it worked. I then upgraded the runtime libraries, and it threw the error.
If this is a bug, it'd be great to get it fixed. If however, this is the intended behavior, then what is the recommedation when databinding to a related entity when it could be null? I'm currently binding directly to an EntityCollection, not to an LLBLGenDataSource2. Is the LLBLGenDataSource2 preferred over the EntityCollection? I can't check for null inside the <%# %> syntax, so should I be doing this in the code-behind? Any advice would be appreciated.
Thanks,
Pete
[edit] This should probably be moved to the 'Generated code' forum. Sorry
.[/edit]