Zxw.Framework.NetCore
1.0.1
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Zxw.Framework.NetCore --version 1.0.1
NuGet\Install-Package Zxw.Framework.NetCore -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Zxw.Framework.NetCore" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Zxw.Framework.NetCore --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Zxw.Framework.NetCore, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Zxw.Framework.NetCore as a Cake Addin #addin nuget:?package=Zxw.Framework.NetCore&version=1.0.1 // Install Zxw.Framework.NetCore as a Cake Tool #tool nuget:?package=Zxw.Framework.NetCore&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
如果有什么问题或者建议,请及时反馈,谢谢。QQ:2336789336,邮箱:victor.tzeng@outlook.com
创建实体类
需要注意的是,所有实体类都必须实现IBaseModel,如果需要在数据库生成对应数据表。
public class TutorClassType:IBaseModel<int>
{
[Key]
[Column("TutorClassTypeId")]
public int Id { get; set; }
[Required]
[StringLength(maximumLength:50)]
public string TutorClassTypeName { get; set; }
public bool Active { get; set; } = true;
[StringLength(maximumLength:200)]
public string Remark { get; set; }
public int TutorClassCount { get; set; }
}
在程序中配置
public class Startup
{
public static ILoggerRepository repository { get; set; }
public Startup(IConfiguration configuration)
{
Configuration = configuration;
//初始化log4net
repository = LogManager.CreateRepository("NETCoreRepository");
Log4NetHelper.SetConfig(repository, "log4net.config");
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public IServiceProvider ConfigureServices(IServiceCollection services)
{
services.AddMvc(option=>
{
option.Filters.Add(new GlobalExceptionFilter());
});
services.AddMemoryCache();//启用MemoryCache
services.AddDistributedRedisCache(option =>
{
option.Configuration = "localhost";//redis连接字符串
option.InstanceName = "";//Redis实例名称
});//启用Redis
services.Configure<MemoryCacheEntryOptions>(
options => options.AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(5)) //设置MemoryCache缓存有效时间为5分钟。
.Configure<DistributedCacheEntryOptions>(option =>
option.AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(5));//设置Redis缓存有效时间为5分钟。
return InitIoC(services);
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseBrowserLink();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseStaticFiles();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
/// <summary>
/// IoC初始化(Autofac)
/// </summary>
/// <param name="services"></param>
/// <returns></returns>
private IServiceProvider InitIoC(IServiceCollection services)
{
var connectionString = Configuration.GetConnectionString("MsSqlServer");
var dbContextOption = new DbContextOption
{
ConnectionString = connectionString,
ModelAssemblyName = "Zxw.Framework.Website.Models",
DbType = DbType.MSSQLSERVER
};
var codeGenerateOption = new CodeGenerateOption
{
ModelsNamespace = "Zxw.Framework.Website.Models",
IRepositoriesNamespace = "Zxw.Framework.Website.IRepositories",
RepositoriesNamespace = "Zxw.Framework.Website.Repositories",
IServicsNamespace = "Zxw.Framework.Website.IServices",
ServicesNamespace = "Zxw.Framework.Website.Services"
};
IoCContainer.Register(Configuration);//注册配置
IoCContainer.Register(dbContextOption);//注册数据库配置信息
IoCContainer.Register(codeGenerateOption);//注册代码生成器相关配置信息
IoCContainer.Register(typeof(DefaultDbContext));//注册EF上下文
IoCContainer.Register("Zxw.Framework.Website.Repositories", "Zxw.Framework.Website.IRepositories");//注册仓储
IoCContainer.Register("Zxw.Framework.Website.Services", "Zxw.Framework.Website.IServices");//注册service
return IoCContainer.Build(services);
}
}
代码生成
生成Repository和Service层代码,在任何Controller里或者新建控制台项目都行,生成之后注释掉就OK
CodeGenerator.Generate();//生成所有实体类对应的Repository和Service层代码文件
CodeGenerator.GenerateSingle<TutorClassType, int>();//生成单个实体类对应的Repository和Service层代码文件
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- Autofac.Extensions.DependencyInjection (>= 4.2.0)
- Dora.Interception (>= 2.0.0-beta1)
- DotNetCore.NPOI (>= 1.0.2)
- log4net (>= 2.0.8)
- Microsoft.AspNetCore.Mvc (>= 2.0.0)
- Microsoft.EntityFrameworkCore (>= 2.0.0)
- Microsoft.EntityFrameworkCore.InMemory (>= 2.0.0)
- Microsoft.EntityFrameworkCore.Relational (>= 2.0.0)
- Microsoft.EntityFrameworkCore.Sqlite (>= 2.0.0)
- Microsoft.EntityFrameworkCore.SqlServer (>= 2.0.0)
- Npgsql.EntityFrameworkCore.PostgreSQL (>= 2.0.0)
- Pomelo.EntityFrameworkCore.MySql (>= 2.0.0)
- Z.EntityFramework.Plus.EFCore (>= 1.7.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
6.1.0 | 916 | 11/20/2022 |
6.0.0 | 1,228 | 1/5/2022 |
5.0.0 | 2,141 | 11/12/2020 |
3.1.4.8 | 2,261 | 10/10/2020 |
3.1.4.7 | 2,143 | 8/7/2020 |
3.1.4.6 | 2,238 | 6/24/2020 |
3.1.4.5 | 2,180 | 6/18/2020 |
3.1.4.4 | 2,122 | 6/13/2020 |
3.1.4.1 | 1,967 | 5/17/2020 |
3.1.4 | 2,145 | 5/16/2020 |
3.1.3.6 | 2,191 | 3/30/2020 |
3.1.3.5 | 2,324 | 2/27/2020 |
3.1.3.3 | 2,506 | 1/17/2020 |
3.1.3.2 | 2,247 | 1/14/2020 |
3.1.3.1 | 2,079 | 1/6/2020 |
3.1.3 | 2,282 | 12/17/2019 |
3.1.2 | 2,442 | 12/17/2019 |
3.1.1 | 2,200 | 12/7/2019 |
3.1.0 | 2,135 | 12/6/2019 |
3.0.0 | 2,152 | 9/28/2019 |
2.2.3.3 | 2,291 | 9/22/2019 |
2.2.3.2 | 2,101 | 9/16/2019 |
2.2.3.1 | 2,161 | 9/15/2019 |
2.2.3 | 2,243 | 9/1/2019 |
2.2.2.5 | 2,230 | 8/29/2019 |
2.2.2.4 | 2,125 | 8/29/2019 |
2.2.2.3 | 2,329 | 8/28/2019 |
2.2.2.2 | 2,156 | 8/11/2019 |
2.2.2.1 | 2,166 | 7/16/2019 |
2.2.2 | 2,561 | 7/10/2019 |
2.2.0 | 2,254 | 7/8/2019 |
2.1.4.62502-rtm-1 | 1,434 | 6/25/2019 |
2.1.4.62501-rtm-1 | 1,517 | 6/25/2019 |
2.1.4.62401-rtm-1 | 1,080 | 6/24/2019 |
2.1.4.62101-rtm-1 | 1,137 | 6/21/2019 |
2.1.4.61405-rtm-1 | 1,163 | 6/14/2019 |
2.1.4.61305-rtm-1 | 1,217 | 6/13/2019 |
2.1.4.61201-rtm-1 | 1,281 | 6/12/2019 |
2.1.4.61101-rtm-1 | 1,128 | 6/11/2019 |
2.1.4.61002-rtm-1 | 1,519 | 6/10/2019 |
2.1.4.61001-rtm-1 | 1,265 | 6/10/2019 |
2.1.4.60501-rtm-1 | 1,203 | 6/5/2019 |
2.1.4.60402-preview2-t007bc... | 1,298 | 6/4/2019 |
2.1.4.60401-preview2-t007bc... | 1,323 | 6/4/2019 |
2.1.4.60301-preview2-t007bc... | 1,517 | 6/3/2019 |
2.1.4.53001-preview2-t007bc... | 1,269 | 5/30/2019 |
2.1.4.52202-preview2-t007bc... | 1,332 | 5/22/2019 |
2.1.4.52201-preview2-t007bc... | 1,524 | 5/22/2019 |
2.1.4.52101-preview2-t007bc... | 1,288 | 5/21/2019 |
2.1.4.52001-preview2-t007bc... | 1,253 | 5/20/2019 |
2.1.4.43002-preview2-t007bc... | 1,481 | 4/30/2019 |
2.1.4.7081-rtm-1 | 1,186 | 7/8/2019 |
2.1.4.429-preview2-t007bc0fad | 1,350 | 4/29/2019 |
2.1.3-preview2-t007bc0fad | 1,148 | 4/18/2019 |
2.1.1-preview2-t007bc0fad | 1,132 | 4/14/2019 |
2.1.0-preview2-t007bc0fad | 1,810 | 2/18/2019 |
2.0.1 | 2,898 | 8/27/2018 |
2.0.0 | 3,242 | 8/16/2018 |
2.0.0-beta2 | 1,677 | 7/7/2018 |
2.0.0-beta | 1,677 | 7/6/2018 |
1.0.7 | 2,483 | 6/11/2018 |
1.0.6 | 2,525 | 5/8/2018 |
1.0.5 | 2,481 | 5/2/2018 |
1.0.4 | 2,650 | 5/1/2018 |
1.0.3 | 2,616 | 4/29/2018 |
1.0.1 | 2,395 | 10/9/2017 |
1.0.0 | 2,122 | 10/8/2017 |