开发者

Stop LINQ to SQL caching

开发者_如何学PythonThe database query run on SQL server (and the actual linq query using SQL Debugger http://weblogs.asp.net/scottgu/archive/2007/07/31/linq-to-sql-debug-visualizer.aspx) show correct data. The object returned shows old data. How do I clear it? Both are doing a select

        Dim s As New StaffRecord
        Dim q = From staff As StaffRecord In db.StaffRecords _
                Where staff.Employee_Number = u.AssignmentNo _
                Select staff
        s = q.First

There is a possibility of 2 staff records with the same employee number, hence using .First instead of .Single


You should create and destroy the datacontext per request. It is designed for that pattern and creates quickly and will prevent stale data.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜