推荐的 asp.net ORM 工具或 SubSonic3 简单存储库的帮助

发布于 2024-08-13 18:26:48 字数 1536 浏览 3 评论 0原文

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

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

发布评论

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

评论(7

初懵 2024-08-20 18:26:48

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.

貪欢 2024-08-20 18:26:48

尝试使用 DataObjects.Net 作为替代方案。它与亚音速完全不同。复合外键、统一键和外键版本适配器(KeyVersionInfo 类型 + Entity.KeyEntity.GetVersion(...)),真正透明的引用(Subsonic 根本不支持引用)和良好的 LINQ 支持只是其中的几个例子。

好的起点是介绍部分(从尾部开始,如果您更喜欢先从其手册中查找示例。

Try DataObjects.Net as an alternative. It is completely different to Subsonic. Composite foreign keys, unified key & version adapters (Key and VersionInfo types + Entity.Key and Entity.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.

谁与争疯 2024-08-20 18:26:48

我真的建议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.

执手闯天涯 2024-08-20 18:26:48

您不应该排除实体框架(或就此而言的 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.

墨小墨 2024-08-20 18:26:48

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.

渡你暖光 2024-08-20 18:26:48

我最近遇到了你的确切问题。如果您使用不相关的单个实体,SimpleRepository 会非常棒。如果您采用模型第一数据库第二范式(我就是这样),那么我建议 Fluent NHibernate与自动映射。网站上的入门内容将帮助您快速启动并运行。唯一的问题是你在建立对外关系时必须小心一点。确保您的主要实体和参考实体都维护彼此的映射,否则 NHibernate 将不会自动级联保存您创建的新参考实体。

即:

(注意:为了简洁起见,菜谱列表是公开的,您可能希望创建一个具有自定义获取/设置属性的内部字段,以在现实生活中公开此集合)

public class Recipe {

    public virtual RecipeBook RecipeBook {get; set;}
    public virtual string RecipeInstructions {get; set;}
}


public class RecipeBook {

    public virtual IList<Recipe> Recipes { get; set; }
    public virtual string BookTitle {get; set;}

    public void AddRecipe(Recipe recipe) {

         recipe.RecipeBook = this;
         Recipes.Add(recipe);
    }

}

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)

public class Recipe {

    public virtual RecipeBook RecipeBook {get; set;}
    public virtual string RecipeInstructions {get; set;}
}


public class RecipeBook {

    public virtual IList<Recipe> Recipes { get; set; }
    public virtual string BookTitle {get; set;}

    public void AddRecipe(Recipe recipe) {

         recipe.RecipeBook = this;
         Recipes.Add(recipe);
    }

}
浮生面具三千个 2024-08-20 18:26:48

如果您使用 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.

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