开发者

Options to display fields from different databases in WPF DataGrid?

I am using .Net 4.0 framework, C#, WPF, EF 4 and FireBird.

I have some data (a multi-field customer number) in a datagrid that comes from a table in one FireBird database. In a second FireBird database I have a table which contains some more information (the customer number again, along with the customer name) that I need to appear in the grid. There are no more than a thousand rows in the tables.

If the tables were in the same database this would be trivial. However, because the FireBird database I'm using does not support cross-database joins, I believe I'll have to join the data at the application level.

Currently I'm displaying only the key values in the grid, but I need to show the customer name from the second database as well. I'm binding the datagrid to list<> produced by a LINQ query against the EF.

I thought that I might set up a second EF model for the second database, and then modify the LINQ query to combine the contents of the two tables into an anonymous class with the required fields.

I'm not sure what other options might be available for doing this.

I could also eliminate the problem by pushing the required table from the second database into the first so that a SQL join can be used. This w开发者_StackOverflow中文版ould have to be done elsewhere in the system and might end up being the preferred solution, but I don't want to go there without evaluating other solutions first.


I went ahead and set up a second entity model against the second database. I set up a class to contain the entity model instances and handle the cross-database interactions (some of this is done with properties on partial classes to model entities). The model view treats the data essentially as a single database. When we get around to moving this stuff into SQL server and getting rid of the dual-database junk the application itself won't have to change much.

The only problem I've run into so far is that I have to be careful when setting up linq queries, combining entities from the two models in one query sometimes generates errors. Not hard to work around though.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜