Im recently struggling with problem related to Linq data exposition. My task is to extract information out of 3 tables. One, which contains list of the resources and the other one with information about related services. These two tables are joined with the junction table. Structure:
Resource Table:
ResourceID (PK)
Description
ServiceResources Table (junction table):
ServiceID(FK)
Resource(FK)
Service Table:
ServiceID (PK)
Description
Version above is simplified, tables are more extended.
So the question is: I generated special object which will contain all the useful information:
public class ResourceAndService
{
public string Resource
{
get;
set;
}
public string Service
{
get;
set;
}(...)
And I want to fill it with informations from the linq query, which should return IList:
public IList<ResourceAndService> ReturnListOfServicesAndResources()
{
var dt = (from res in entities.Resource
from service in entities.Service
select
new ResourceAndService(){
Resource = res.ResourceID,
Service= ser.ServiceID,
(...)
}).ToList();
return dt;
}
Unfortunately continuously, when I try to execute this command, there are warnings in the debug window saying:
A first chance exception of type 'System.NullReferenceException' occurred in RaportBrowser.DLL
And query never finishes.
Do you have any experience with such a problem?