In datacontext, a table is added,CodeAs follows:
/// <Summary>
/// Data access context
/// </Summary>
Public Class Sysdatacontext: datacontext
{
Public Static String Dbconnectionstring =" Data Source = isostore:/sys. SDF; Case Sensitive = true; " ;
Public Sysdatacontext ()
: Base (Dbconnectionstring)
{
}
Public Table <tabletestentity> tabletestentities { Get ; Set ;}
}
As a result, when accessing tabletestentities, a blank reference exception is prompted. Modify the following to solve the problem:
/// <Summary>
/// Data access context
/// </Summary>
Public Class Sysdatacontext: datacontext
{
Public Static String Dbconnectionstring = " Data Source = isostore:/sys. SDF; Case Sensitive = true; " ;
Public Sysdatacontext ()
: Base (Dbconnectionstring)
{
}
Public Table <tabletestentity> tabletestentities; // {Get; set ;}
}
Linqtosql reflects that the query should be based on field, rather than the property, leading to a null reference error.