Home > Net >  From the data values
From the data values

Time:01-25

I use c # winform using ADO.net

I am to have such a list pc_info, there is a field in the table stauts

PcsystemEntities db=new pcsystemEntities ();

Private void the read ()
{
Var pcinfo=db. Pc_info. Where (x=& gt; X.p c_code=="123"). ToList ();

If (pcinfo stauts==1) {
,,,,,,,
}

}

Normal can be read from the data to the corresponding values,



The question now is:

1, the interface's not
2, I manually from the database, the status=1 - & gt; Change the status=2
3, in the interface, to perform, the query button to read (), on the interface to the value of the status or 1

After I closed, only the interface to open, will be loaded into the new value status=2, is difficult to query I write wrong, or what
I see linq to database select statement is to be able to check the latest value,
But at the time of return, or with the old values,


I want the result is:
1, as long as there is modified in the database, the interface, in not to open the case, I can perform the query to get the current value of the latest

CodePudding user response:

Then it's not tracking bai, use AsNoTracking () data is read-only,, so every time of query from the database, the defect is within the context of no data records to update

 
Var pcinfo=db. Pc_info. Where (x=& gt; X.p c_code=="123"). AsNoTracking () ToList ();
  •  Tags:  
  • C#
  • Related