Simple CRUD Generator for C# [closed]

一笑奈何 提交于 2019-12-31 15:50:41

问题


I am looking for a simple CRUD (or DAL) Generator for C#. I don't want anything heavyweight since I only have a couple of tables in a SQL Server 2008 database.

Any suggestions? I know .netTiers, but it is way too much for what I need.

Thanks!

UPDATE: I tried LINQ to SQL and it doesn't work well for my needs.


回答1:


I have used SubSonic on past projects, it's lightweight and easy to use.

They offer a simple tutorial video and it should take no more than 10 minutes to get it completely setup. I recommend watching the second half of the video that deals with Web Application Projects because it shows you how to create a customized Visual Studio button that creates the DAL for you whenever you click on it instead of using a custom build-provider as they suggest in first half of the video.

It offers several ways to access your data, Active Record, generating typed stored-procedures and views, or a query language that you can use.

After using it, I have found a few quirks:

  • If you use a generated stored-procedure that does not have a parameter, it will throw a NullReferenceException. A workaround is to create a dummy parameter that isn't used in the procedure
  • The DeepSave() function does not work in the current 2.1 version, you'll have to individually save data from joined tables
  • When you use a coditional (e.g. Where(Tag.Columns.TagName).IsEqualTo("subjective"), make sure you use the string value Tag.Columns.TagName to reference the column - otherwise an exception will be thrown if you try to use the Column.Schema



回答2:


Visual Studio comes with a code generator that hardly anyone knows about called T4.

You should be able to use it relatively easily to create CRUD templates.

EDIT

And here's an example how: http://www.olegsych.com/2008/01/how-to-use-t4-to-generate-crud-stored-procedures/




回答3:


MyGeneration has some pretty good CRUD SP generation templates




回答4:


try http://pureobjects.com/ it is not need any other work




回答5:


What about using a DataSet created using the DataSet designer. I remember back in the Old Days (.NET 1.0 and 1.1), we would drag a DataAdapter onto the design surface, specify the Select query, and the Insert, Update and Delete queries would be created for us, based on the Select query.




回答6:


Just in case money isn't a big concern, I've had great success with templates in CodeSmith.

There are plenty of sample templates out there for CRUD operations and it'll read directly from your database.




回答7:


Take a look at Codesmith. The 2.6 version is free and the later versions are for purchase.




回答8:


LINQ To SQL is easy and it's built into .NET 3.5 SP1.




回答9:


The Visual Studio wizards will create a simple CRUD app for you.

Drag a datagrid on your form, click the connection property and follow the wizards from there.

Not best practices but is simple and works...




回答10:


Have you tried the Dynamic Data Web Application (uses LINQ to SQL) or the Dynamic Data Entities Web Application (uses Entity Framework).

MSDN: Walkthrough: Creating a New ASP.NET Dynamic Data Web Site Using Scaffolding




回答11:


I use ssms tools pack




回答12:


I was using SubSonic 3 ActiveRecord but have since moved to BLToolkit. BLToolkit is much harder to get started with due to the lack of good documentation, but once you get used to it, it's very much like SubSonic... except for without the performance issues.

SubSonic is great and easy but the performance is unbearable for anything practical. Anytime a join or subquery is done it will pull down entire tables.




回答13:


Check out LLBLGen Pro, I swear by it. It is not free, but not expensive. You can get up and running (writing code) within an hour, and the templates it comes with generate code that can do basically anything you would want. It is so nice (and productive) to not even have to think about database interface code anymore.



来源:https://stackoverflow.com/questions/672020/simple-crud-generator-for-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!