句容网站建设开发,万户信息 做网站怎么样,wordpress表格折叠插件,58网站 做现浇混凝土.NET AOT8 基本上能够免强使用了, SqlSugar ORM也支持了CRUD 能在AOT下运行了
Nuget安装
SqlSugarCore
具体代码
StaticConfig.EnableAot true;//启用AOT 程序启动执行一次就好了//用SqlSugarClient每次都new,不要用单例模式
var db new SqlSugarClient(new ConnectionC….NET AOT8 基本上能够免强使用了, SqlSugar ORM也支持了CRUD 能在AOT下运行了
Nuget安装
SqlSugarCore
具体代码
StaticConfig.EnableAot true;//启用AOT 程序启动执行一次就好了//用SqlSugarClient每次都new,不要用单例模式
var db new SqlSugarClient(new ConnectionConfig(){IsAutoCloseConnection true,DbType DbType.Sqlite,ConnectionString datasourcedemo.db },it {// Logging SQL statements and parameters before execution// 在执行前记录 SQL 语句和参数it.Aop.OnLogExecuting (sql, para) {Console.WriteLine(UtilMethods.GetNativeSql(sql, para));};});return db;
已支持功能
//查询
var listdb.QueryableStudent().ToList();
var list2db.QueryableStudent().ToDataTable();
var list3 db.QueryableStudent().Select(itnew { idit.Id
}).ToList(); //插入 、删除和更新只要是实体目前测试下来 都OK
db.Insertable(new Student()
{Id 1,Name aa
}).ExecuteCommand();
db.Deleteable(new Student()
{Id 1,Name aa
}).ExecuteCommand();
db.Updateable(new Student()
{Id 1,Name aa
}).ExecuteCommand();//写sql也支持
db.Ado.GetDataTable(sql);
db.Ado.ExecuteCommand(sql);
不支功能
//部分库建表不支持
//动态建类不支持
AOT配置教程
创建一个带AOT的类项目 新建一个rd.xml
DirectivesApplicationAssembly NameSqlSugar DynamicRequired All/Assembly /Application
/Directives
改项目文件
Project SdkMicrosoft.NET.Sdk.WebPropertyGroupTargetFrameworknet8.0/TargetFrameworkNullableenable/NullableImplicitUsingsenable/ImplicitUsingsInvariantGlobalizationtrue/InvariantGlobalizationPublishAottrue/PublishAotPlatformsAnyCPU;x64/Platforms/PropertyGroupItemGroupRdXmlFile Includerd.xml //ItemGroup
RdXmlFile这个重点引用我们新建的rd.xml (这个xml要能发布出去)