如何使用代码为CRUD操作(如Visual Studio)生成整个样板代码? [英] How to generate whole boiler plate code for CRUD operations like visual studio using code?

查看:130
本文介绍了如何使用代码为CRUD操作(如Visual Studio)生成整个样板代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为数据库表的实体生成CRUD操作,例如要使用的各个端点.

I am trying to generate CRUD operations for entities of my database tables like with respective endpoints to consume.

这与Visual Studio生成用于身份验证(帐户控制器)的样板代码以及以整包形式进行原始操作一样.

It is same as the visual studio generates boiler plate code for Authentication(Account controller),and also crud operation in the form of whole package.

我遇到过t4模板,但是没有得到如何使用它为我的数据库表实体生成Crud操作的信息.

I have came across t4 templates but not getting how to use it to generate crud operations for my database table entities.

我还试图使用应用程序名称,references(dll),Controller等来生成整个应用程序包.例如,Visual Studio如何为实体框架的CRUD操作生成样板代码.

I am also trying to generate whole application package with Application name,references(dll),Controller etc.. like how visual studio is generating boiler plate code for CRUD operations for entity framework.

我将传递要为其生成的sql服务器名称,数据库名称,表CRUD操作.

I will pass sql server name,database name,tables for which i want to generate CRUD operations.

我想通过我的控制台应用程序按需生成此文件,因此它应该返回带有引用s(all dll)的整个应用程序包,因此我将创建该程序包的zip并返回给用户.

I want to generate this on demand with my console application so it should return whole application packages with reference s(all dll) so then i will create zip of that packages and return to user.

对于例如:我想基于应用程序名称"生成我的整个应用程序包,如下WebApplication3项目中所示,其中包含References,Controller包含Crud操作

For Eg:I want to generate my whole apllication package based on "Application name" as shown in below WebApplication3 project which contains References,Controller which contains crud operations

有人可以告诉我该怎么做吗?

Can anybody tell me how to do this?

推荐答案

您可以使用Telosys之类的生成器,它具有一个与实体框架一起使用的C#MVC模板.

You could use a generator like Telosys, it has a C# MVC Template working with entity framework.

如果您有数据库模型,则可以使用此模板将其传递给生成器,它将生成用C#编写的可工作的CRUD应用程序,您可以在项目中重用.

If you have a database model, you can pass it to the generator with this template and it will generate a working CRUD application written in C# that you can reuse in your project.

http://telosys.org/

要使用的模板: https://github.com/telosys-templates-v3/telosys-template-mvc-csharp

这篇关于如何使用代码为CRUD操作(如Visual Studio)生成整个样板代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆