English 中文(简体)
如何利用背景工作者在实体框架中适当使用背景
原标题:How to properly use Object Contexts in Entity Framework using BackgroundWorker

我正在利用实体框架和世界森林论坛,我遇到了一些错误,我不知道为什么。 在保存记录(使用<代码>BackgroundWorker)时,我确定各实体改轨为零(null),将记录附在新的可支配背景之下,但以该记录为准,并处理具体情况。

可在<条码>上发布记录火灾和事件 MainViewModel of the program that the other 意见书(包括正在储蓄的代码)需要更新其实体以反映变化。

Private Sub _saveRecordWorker_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles _saveRecordWorker.DoWork
    Using MyContext As New RVShippingEntities
        Dim MyShipment = CType(ShipmentRecord, IEntityWithChangeTracker)
        MyShipment.SetChangeTracker(Nothing)
        MyContext.Attach(MyShipment)
        MyContext.Detach(ShipmentRecord)
    End Using
End Sub

The Refresh background worker is similar, but it has a Do While block to keep it from interfering with the save worker (which doesn t appear to be working; hence the post). When I save (and it subsequently refreshes) I get the following error: The calling thread cannot access this object because a different thread owns it.

我认为,随着“<>日码/代码>的封条,它会等到(如果我通过它这样做的话),直到“午线”结束,而且所有这一切都将是好的。 但是,似乎有些东西(主线或救助线)仍在进行干涉。

是否有更好的办法这样做? 我用 go子做这件事吗? 希望得到任何帮助。

(Apoulo)承认判决为一字。 利息

最佳回答

因此,就实体框架而言,3+个月和零为例外。 我将提出这一答案。

父母意见(就我的案件而言,客户、船舶)有一个必要的背景,可以向儿童提出意见(地址、电话Nus、电子邮件地址、公司和客户;包装材料、内容、船舶)。 任何情况都可能节省变化或你认为什么(db脱节是最常见的原因)、情况得到处置、新的分析、实体重新调整、(根据我对国际不动产公司所做的习惯改变追踪)以及变化得到挽救。

问题回答

暂无回答




相关问题
Entity Framework with MySQL connector in c#

I have been trying to get the Entity Framework to work in my web application using MySQL. It works fine on my local pc, but doesn t work when I put it on the server. Since the server is a shared ...

How Do I Create And Update A Many To Many Relationship With EF

I am using the Entity Framework with SQL Server. I have a many to many relationship between 2 tables. I have created a join table with just the primary key fields of the 2 tables. In the designer, the ...

Entity Framework with File-Based Database

I am in the process of developing a desktop application that needs a database. The application is currently targeted to SQL Express 2005 and works wonderfully. However, I m not crazy about having ...

Linq to enties, insert foreign keys

I am using the ADO entity framework for the first time and am not sure of the best way of inserting db recored that contain foreign keys. this is the code that i am using, I would appreciate any ...

Entity Framework - Many to many question

I have a table called ASB and a table called PeopleInvolved. There is a junction table called PeopleInvolved_ASB which simply contains an ASBID and a PeopleInvolvedID column. The columns act as a ...

Post back complex object from client side

I m using ASP.NET MVC and Entity Framework. I m going to pass a complex entity to the client side and allow the user to modify it, and post it back to the controller. But I don t know how to do that ...

ADO.NET Entity Data Model are not precise enough

I run this code: var cos = from k in _db.klienci_do_trasy where k.klient_id == 5 select k; but the query send to database is: SELECT * FROM `klienci_do_trasy` LIMIT 0, 30 why is it for, there ...