与 Subsonic 中的关系合作

发布于 2024-09-12 22:40:53 字数 1421 浏览 5 评论 0原文

我在我的 winforms 项目中使用 subsonic 3.0.3(ActiveRecords)。我正在努力为我的实体使用集合,但到目前为止我还无法做到这一点。

请允许我更清楚地表达自己。

在浏览许多教程时,我发现 Subsonic 将生成两个类。一个是集合类,另一个是实体对象。举例来说,如果我的数据库中有一个人员表,则 subsonic 将生成一个人员实体类和一个人员集合类。一个网站(抱歉,我忘记了,是哪一个)也提到我需要使用一个名为 SubsonicCommands 的工具来执行这种亚音速操作。我从这个网站下载了 Visual Studio 2008 的相同版本 http://oldtownit.com/media/files/SubSonicToolsSetup.zip

我可以运行工具并生成类,但项目不会编译,因为它正在寻找此类 SubSonic.Utilities。请教一下,哪里可以找到这门课?我尝试在 ~\Program Files\Subsonic\SubSonicTools\source\ 中寻找此类,但找不到它。

另外,我检查了代码,集合类仍然没有生成。在我尝试的上述情况下,生成了两个类,Person Entity Class 和 PersonController Class

My AIM :

我试图用 subonic 做的是 LLBLGEN 的工作方式。

LLBLGEN 示例举例

来说,如果有两个表 Items 和 Supplyrs,它们是一个名为 ItemSuppliers 的中间表,它与这两个表(Items 和 Supplyers)具有多对一关系,那么在 LLBLGEN 中,我可以执行类似

Item 的 操作item = new Item(ItemFields.ItemId==1); item.ItemSuppliers.DeleteMulti()

将删除 ItemSuppliers 表中与 ItemId 为 1 的项目相关的所有记录。这也可以针对供应商表完成(当然进行适当的更改)

另外我想知道,如果我返回父对象,我是否可以返回特定项目的所有 ItemSuppliers (来自上面的示例)。

又是 LLBLGEN 的一个例子 项目项 = 新项目(ItemFields.ItemId ==1); MessageBox.Show(item.ItemSuppliers.Count.ToString());

如果某个物品有 2 个供应商(来自 itemSuppliers 表),上面的消息框将显示 2

尾声:

Subsonic 是一个很棒的工具。我经常在一些超小型项目中使用它,但我想在一些更复杂的项目中使用它,这次它在表之间有一些关系。

另外,如果有人可以建议,如果我能做到,我想用亚音速做什么,那将是非常棒和甜蜜的。

I am using subsonic 3.0.3(ActiveRecords) in my winforms project. I am trying very hard to use Collections for my entities but so far I have been unable to do that .

Please allow me to make myself more clear.

While going across many tutorials, I have seen, that Subsonic will generate two classes. One is a collection class and the other the entity object. say for example, if i have a person table in my database, subsonic will generate a Person Entity class and a PersonCollection class. A website(sorry, i forgot, which one) also mentioned that I need to use a tool called SubsonicCommands to perform this kind of operatin with subsonic. I downloaded a version of the same for Visual Studio 2008 from this website
http://oldtownit.com/media/files/SubSonicToolsSetup.zip

I can run the tool and generate the classes, but the project wont compile , because it is looking for this class SubSonic.Utilities. Pray, tell me where can I find this class? I tried looking for this class, in the ~\Program Files\Subsonic\SubSonicTools\source\ but could not find it.

Also, I checked the code,The collection class was still not being generated. In the above case that I tried, there were two classes generated, Person Entity Class and the PersonController Class

My AIM :

What I am trying to do with subonic is the how LLBLGEN works.

LLBLGEN Example

say for example, if there are two tables, Items and Suppliers and their is an intermediate table called ItemSuppliers which has a many to one relation with both the tables (Items and Suppliers), then in LLBLGEN ,I can do something like

Item item = new Item(ItemFields.ItemId==1);
item.ItemSuppliers.DeleteMulti()

which would delete all the records related to an item whose ItemId is 1 in the ItemSuppliers table. This can also be done with respect to the Suppliers table (of course making the proper changes)

Also I would like to know, If i can return all the ItemSuppliers for a particular item (from the example above) if i returned the parent object .

again an example from LLBLGEN
Item item = new Item(ItemFields.ItemId ==1);
MessageBox.Show(item.ItemSuppliers.Count.ToString());

The above message box would dispaly 2 if there were 2 suppliers for an Item (from the itemSuppliers table)

Epilogue:

Subsonic is an awesome tool to work with. I have used it often , in some ultra small projects, but I would like to use it with a little bit more complicated project,this time which has some relations between tables.

Also, if somebody could suggest , if I can do , what I want to do with subsonic , that would be awesome and sweet.

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

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

发布评论

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

评论(1

苏辞 2024-09-19 22:40:53

您首先说您正在使用版本 3.0.2,但似乎您正在使用 Subsonic 2.2 和 3 - 您应该使用其中之一。

版本 2 中的实用程序类。
可从以下位置下载: http://github.com/subsonic/SubSonic -2.0/blob/master/SubSonic/Utility.cs

You start by saying you're using version 3.0.2 but it seems you're using Subsonic 2.2 and 3 - You should use one or the other.

The utlities class in version 2.
Downloadable from: http://github.com/subsonic/SubSonic-2.0/blob/master/SubSonic/Utility.cs

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