C# (WPF):数据库关系查看器

发布于 2024-09-15 00:32:37 字数 451 浏览 6 评论 0原文

我想用 C# 创建一个 WPF 应用程序,它可以以用户界面友好的方式直观地显示从应用程序用户(MS SQL Server、MS Access、Oracle、MySQL 等)并允许编辑关系。

例如,在 Microsoft Access 2007 中,可以通过至少有 2 个表并单击数据库工具选项卡,然后单击关系。另一个例子是在 Microsoft SQL Server 中创建数据库图表时。

第一步是创建一个数据访问层以允许连接到不同类型的数据库(取决于提供程序类型)。

我不知道 .NET 中是否已经有某种查看器(或者可能是免费的第三方库)可以做到这一点。你认识一个吗?如果不是,使用 WPF 手动执行此操作的主要步骤是什么?

感谢您的任何帮助和建议!

I would like to create a WPF application in C# that can show visually, in a user interface friendly way, the relationships between tables from a database chosen from the application user (MS SQL Server, MS Access, Oracle, MySQL, etc.) and allow the editing of the relationships.

For example, in Microsoft Access 2007 it is possible to do such a thing by having at least 2 tables and clicking on the Database Tools tab and then on Relationships. Another example is in Microsoft SQL Server when creating a diagram of the database.

The first step would be to create a data access layer to allow the connection to different types of databases (depending on the provider type).

I am not aware if there is already some sort of viewer in .NET (or maybe a free third party library) that could do the trick. Do you know one? If not what are the big lines for doing it manually with WPF?

Thank you for any help and suggestions!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

蛮可爱 2024-09-22 00:32:37

您也许可以查看 MS Access 2007 的 MS Office PIA,看看是否可以找到您正在谈论的查看器...

You could maybe have a look at the MS Office PIAs for MS Access 2007 and see if you can find the viewer you are talking about...

简美 2024-09-22 00:32:37

这里有很多“大门票”项目,但我们将从核心功能开始。

数据库任务:
枚举表
对于每个表 - 枚举关系。
为您希望处理的每种数据库类型抽象上述功能。

用户界面任务:
布置桌子(简单的相同尺寸的盒子)
为每个关系画线
实施拖放放置 - 在放置时重绘关系线。

现在,这并不能处理漂亮的曲线,也不能很好地路由这些线
它也不处理表格列,因此 UI 中的所有表格“框”大小相同,从而简化了布局。

但这种级别的功能作为概念证明是一个很好的目标。

如果这是针对专业客户的,请不要在上面浪费时间。

但是,如果是为了学习经验,那就去吧!从这样的项目中可以获得很多有价值的东西,您将在您的编程生涯中一次又一次地使用它们。

希望这有帮助!

There's a good number of 'Big Ticket' items here, but we'll start from the core functionality.

DB Tasks:
Enumerating the Tables
For each table- enumerate relationships.
Abstract above functionality for each DB type you wish to deal with.

UI Tasks:
Lay out tables (simple same size boxes)
draw lines for each relationship
Implement Drag & Drop - redraw relationship lines on drop.

Now, this doesn't deal with nice curved lines, and routing those lines nicely
It also doesn't deal with the table columns, so all the table 'boxes' in the UI are the same size, which simplifies layout.

But this level of functionality is a good goal as a proof of concept.

If this is for a client, in a professional capacity, dont waste your time on it.

However if it is for the learning experience then go for it! There's lots of nice nuggets to be gained from a project like this that you will use again and again in your programming career.

hope this helps!

眸中客 2024-09-22 00:32:37

读取外键关系可能并不简单。我的申请包括以下评论:

//get the list of all foreign keys
//unfortunately GetSchema doesn't return the column definitions
//http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=741870&SiteID=1 suggests getting this
//information from the the sys.foreign_keys catalog view joined with sys.objects (for SQL 2005)
//or from the sysforeignkeys and sysobjects tables in SQL 2000).

Reading the foreign key relationships may be non-trivial. My application includes the following comment:

//get the list of all foreign keys
//unfortunately GetSchema doesn't return the column definitions
//http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=741870&SiteID=1 suggests getting this
//information from the the sys.foreign_keys catalog view joined with sys.objects (for SQL 2005)
//or from the sysforeignkeys and sysobjects tables in SQL 2000).
緦唸λ蓇 2024-09-22 00:32:37

它不是免费的,但对于任何 WPF 图表,我总是使用 Mindscape 的图表产品 WPF 流程图。该产品很棒,支持也很棒。

It's not free, but for any WPF diagramming I would always use Mindscape's diagramming product WPF Flow Diagrams. The product is great and the support is superb.

2024-09-22 00:32:37

Visual Studio 中内置了此类查看器,请转到“工具”->“工具”->“工具”->“工具”。连接到数据库,并将其全部连接到数据库。然后,当您在服务器资源管理器上看到数据库时,打开一个表并查看工具栏中的不同按钮,其中一个按钮会将表显示为灰色背景上的小窗口。打开该窗口后,您可以将其他表拖/放到灰色区域中,它将显示所有关系。

There is a viewer of this sort built into visual studio, go to Tools-> Connect to Database, and get it all hooked up to the database. Then when you see the database on the Server Explorer, open a table and look at the different buttons in your toolbar, there's one that will bring the table up as a little window on a grey background. Once you've got that window open, you can drag/drop other tables into the gray area and it will show you all there relationships.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文