开发者

LINQ to SQL - two same databases

I have two SQL se开发者_如何学Pythonrvers with the same database. Now I want to copy some data from the first to the second. I created two LINQ to SQL classes, but when I write the query I get an error because of name collisions. How can I avoid this?


If the schema is the same (like it sounds), you should be able to use the same model, but just use different connection-strings / connections to initialize two data-context instances. The problem however, is likely to be detaching objects from one model to pass to the other, and all the primary key goodness. In essence, I would recommend copying the objects and passing different objects with different keys to the second model.

Also, if the volume is very high, you might find SqlBulkCopy coupled to SqlDataReader useful; but that doesn't use LINQ-to-SQL at all.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜