mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-19 04:18:16 +08:00
增加 FreeSql.Extensions.BaseEntity 项目
This commit is contained in:
@ -24,9 +24,7 @@ BaseEntity 是一种极简单的 CodeFirst 开发方式,特别对单表或多
|
||||
|
||||
# 声明
|
||||
|
||||
参考 BaseEntity.cs 源码(约100行),copy 到项目中使用,然后添加 nuget 引用包:
|
||||
|
||||
> dotnet add package FreeSql.Repository
|
||||
> dotnet add package FreeSql.Extensions.BaseEntity
|
||||
|
||||
> dotnet add package FreeSql.Provider.Sqlite
|
||||
|
||||
@ -60,25 +58,6 @@ public class User : BaseEntity<UserGroup, Guid>
|
||||
}
|
||||
```
|
||||
|
||||
3、定义多主键的实体类型,可以在 static 构造函数中重写字段名;
|
||||
|
||||
```csharp
|
||||
public class User2 : BaseEntity<User2, Guid, int>
|
||||
{
|
||||
static User2()
|
||||
{
|
||||
User2.Orm.CodeFirst.ConfigEntity<User2>(t =>
|
||||
{
|
||||
t.Property(a => a.PkId1).Name("UserId");
|
||||
t.Property(a => a.PkId2).Name("Index");
|
||||
});
|
||||
}
|
||||
|
||||
public string Username { get; set; }
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
# CRUD 使用
|
||||
|
||||
```csharp
|
||||
|
Reference in New Issue
Block a user