Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 11 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(7)
Mindscape 的 LightSpeed 通常非常简单(它采用约定优于配置的方法),并自动处理您描述的列表场景。尽管它在表面下需要外键 ID,但它有一个设计器,可以为您添加这些 ID(您可以拖动表,或使用设计器创建关联,设计器将自动实现外键)。有关示例,请参阅截屏视频入门。
Mindscape's LightSpeed is generally pretty simple (it takes a convention over configuration approach), and automatically handles the list scenario you describe. Although it requires foreign key IDs under the surface, it has a designer which will take care of adding those for you (you can drag tables on, or create associations using the designer and the designer will automatically implement the foreign keys). See the getting started screencast for an example.
尝试使用 DataObjects.Net 作为替代方案。它与亚音速完全不同。复合外键、统一键和外键版本适配器(
Key
和VersionInfo
类型 +Entity.Key
和Entity.GetVersion(...)
),真正透明的引用(Subsonic 根本不支持引用)和良好的 LINQ 支持只是其中的几个例子。好的起点是介绍部分(从尾部开始,如果您更喜欢先从其手册中查找示例。
Try DataObjects.Net as an alternative. It is completely different to Subsonic. Composite foreign keys, unified key & version adapters (
Key
andVersionInfo
types +Entity.Key
andEntity.GetVersion(...)
), truly transparent references (Subsonic does not support references at all) and good LINQ support are just few examples of what's there.Good starting point is introduction part (start from the tail, if you prefer to look up an example first) from its Manual.
我真的建议NHibernate,一旦你进入它,它一点也不复杂,并且会为你提供大量的功能,而不是将你锁定在一种思维模式中。自从我开始使用它以来,我就没有回头过,并且体验过其他一些 ORM,但从未给我留下过深刻的印象。
I really suggest NHibernate, it's not that complex at all once you get into it, and will provide you with a huge range of features instead of locking you into one mindset. I haven't looked back since I started using it, and have experienced some other ORM's but have never been amazingly impressed.
您不应该排除实体框架(或就此而言的 LINQ to SQL)。
我之所以说实体框架优于 LINQ to SQL,是因为实体框架提供了从实体图创建数据库的能力(实体图应该很容易从类生成)。
它们都内置于 .NET 中,因此可以立即使用,并且麻烦最少。
You shouldn't exclude Entity Framework (or LINQ to SQL for that matter).
The reason I said Entity Framework over LINQ to SQL is that the Entity Framework provides the ability to create the database from an Entity diagram (which should be easy to generate from your classes).
Both of those are built in to .NET so they're immediately available with minimal hassle.
NHibernate 岩石。我很快就提高了工作效率。查看 nhibernate 之夏,获取精彩的免费培训视频。它们适用于旧版本,但您应该能够在使用过程中找出差异。
NHibernate rocks. I was productive fairly quickly with it. Check out summer of nhibernate for great free training videos. They're for an older version but you should be able to figure out the differences as you go.
我最近遇到了你的确切问题。如果您使用不相关的单个实体,SimpleRepository 会非常棒。如果您采用模型第一数据库第二范式(我就是这样),那么我建议 Fluent NHibernate与自动映射。网站上的入门内容将帮助您快速启动并运行。唯一的问题是你在建立对外关系时必须小心一点。确保您的主要实体和参考实体都维护彼此的映射,否则 NHibernate 将不会自动级联保存您创建的新参考实体。
即:
(注意:为了简洁起见,菜谱列表是公开的,您可能希望创建一个具有自定义获取/设置属性的内部字段,以在现实生活中公开此集合)
I faced your exact problem recently. SimpleRepository is fantastic if you're using single entities that arent related. If you are set on the model-first-database-second paradigm (which I was) then I would suggest Fluent NHibernate with automappings. The getting started stuff on the website will have you up and running quickly. The only gotcha is that you have to be a little careful about creating foreign relationships. Make sure both your primary entity and your reference entity both maintain a mapping to each other, otherwise NHibernate will not automatically cascade save a new reference entity you create.
Ie:
(note: list of recipes is public for sake of brevity, you probably want to create an internal field with a custom get/set properties to expose this collection in real life)
如果您使用 SQL Server 作为后端数据库,我建议使用 Linq to Sql 并使用 VS2008 附带的 SQLMetal 工具。您几乎可以完成 NHibernate 所做的所有事情,并且无需费力(更不用说没有烦人的 xml),只需在 VS2k8 命令行提示符下运行命令即可。最好的开始资源是 Scott Gu 的介绍 此处,然后是一些 SQLMetal 文档< /a>.
If you are using SQL server as your backend database, I would suggest using Linq to Sql and using the SQLMetal tool that ships with VS2008. You can do just about everything that NHibernate does and you dont have to lift a finger (not to mention no pesky xmls), just run a command on the VS2k8 Command line prompt. The best resource to start would be Scott Gu's introduction available here and then some SQLMetal documentation.