I have written the linq query like:
NorthwindContext context = SqlCE;
var query = context.Destinations.Where(i => i.Id >= 1).Select(i => new {
id = i.Id,
name = i.Destination
}).ToArray();
public NorthwindDataContext SqlCE
{
get
{
AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting", true);
string connectionString = @"Data Source=|DataDirectory|\Database1.mdf";
return new NorthwindDataContext(connectionString);
}
}
I have connected to sqlserver northwind.mdf file. I have values in the table also still i am getting null reference exception. How can i rectify this. How to get values in to the query.
Regards
You’ll probably need something like that:
Although there may be more you may be missing (e.g. connection strings, etc).