This commit is contained in:
28810 2018-12-26 20:29:41 +08:00
parent 070254127d
commit 7d8e513477
2 changed files with 66 additions and 15 deletions

View File

@ -1,10 +1,63 @@
# CodeFirst # CodeFirst
| 数据库 | 支持的类型类型 | ## 映射映射
| - | - |
| MySql | bool, sbyte, short, int, long, byte, ushort, uint, ulong, double, float, decimal, Guid, TimeSpan, DateTime<br>bool?, sbyte?, short?, int?, long?, byte?, ushort?, uint?, ulong?, double?, float?, decimal?, Guid?, TimeSpan?, DateTime?<br>byte[], string, Enum & FlagsEnum<br>MygisPoint, MygisLineString, MygisPolygon, MygisMultiPoint, MygisMultiLineString, MygisMultiPolygon |
| SqlServer | bool, sbyte, short, int, long, byte, ushort, uint, ulong, double, float, decimal, Guid, TimeSpan, DateTime, DateTimeOffset<br>bool?, sbyte?, short?, int?, long?, byte?, ushort?, uint?, ulong?, double?, float?, decimal?, Guid?, TimeSpan?, DateTime?, DateTimeOffset?<br>byte[], string, Enum & FlagsEnum |
| csharp | MySql | SqlServer | PostgreSQL |
| - | - | - | - |
| bool \| bool? | bit(1) | bit | bool |
| sbyte \| sbyte? | tinyint(3) | smallint | int2 |
| short \| short? | smallint(6) | smallint | int2 |
| int \| int? | int(11) | int | int4 |
| long \| long? | bigint(20) | bigint | int8 |
| byte \| byte? | tinyint(3) unsigned | tinyint | int2 |
| ushort \| ushort? | smallint(5) unsigned | int | int4 |
| uint \| uint? | int(10) unsigned | bigint | int8 |
| ulong \| ulong? | bigint(20) unsigned | decimal(20,0) | numeric(20,0) |
| double \| double? | double | float | float8 |
| float \| float? | float | real | float4 |
| decimal \| decimal? | decimal(10,2) | decimal(10,2) | numeric(10,2) |
| Guid \| Guid? | char(36) | uniqueidentifier | uuid |
| TimeSpan \| TimeSpan? | time | time | time |
| DateTime \| DateTime? | datetime | datetime | timestamp |
| DateTimeOffset \| DateTimeOffset? | - | - | datetimeoffset |
| Enum \| Enum? | enum | int | int4 |
| FlagsEnum \| FlagsEnum? | set | bigint | int8 |
| byte[] | varbinary(255) | varbinary(255) | bytea |
| string | varchar(255) | nvarchar(255) | varchar(255) |
| MygisPoint | point | - | - |
| MygisLineString | linestring | - | - |
| MygisPolygon | polygon | - | - |
| MygisMultiPoint | multipoint | - | - |
| MygisMultiLineString | multilinestring | - | - |
| MygisMultiPolygon | multipolygon | - | - |
| BitArray | - | - | varbit(64) |
| NpgsqlPoint \| NpgsqlPoint? | - | - | point |
| NpgsqlLine \| NpgsqlLine? | - | - | line |
| NpgsqlLSeg \| NpgsqlLSeg? | - | - | lseg |
| NpgsqlBox \| NpgsqlBox? | - | - | box |
| NpgsqlPath \| NpgsqlPath? | - | - | path |
| NpgsqlPolygon \| NpgsqlPolygon? | - | - | polygon |
| NpgsqlCircle \| NpgsqlCircle? | - | - | circle |
| (IPAddress Address, int Subnet) \| (IPAddress Address, int Subnet)? | - | - | cidr |
| IPAddress | - | - | inet |
| PhysicalAddress | - | - | macaddr |
| NpgsqlRange<int> \| NpgsqlRange<int>? | - | - | int4range |
| NpgsqlRange<long> \| NpgsqlRange<long>? | - | - | int8range |
| NpgsqlRange<decimal> \| NpgsqlRange<decimal>? | - | - | numrange |
| NpgsqlRange<DateTime> \| NpgsqlRange<DateTime>? | - | - | tsrange |
| PostgisPoint | - | - | geometry |
| PostgisLineString | - | - | geometry |
| PostgisPolygon | - | - | geometry |
| PostgisMultiPoint | - | - | geometry |
| PostgisMultiLineString | - | - | geometry |
| PostgisMultiPolygon | - | - | geometry |
| PostgisGeometry | - | - | geometry |
| Dictionary<string, string> | - | - | hstore |
| JToken | - | - | jsonb |
| JObject | - | - | jsonb |
| JArray | - | - | jsonb |
> 以上类型和长度是默认值,可手工设置,如 string 属性可指定 [Column(DbType = "varchar(max)")]
```csharp ```csharp
IFreeSql fsql = new FreeSql.FreeSqlBuilder() IFreeSql fsql = new FreeSql.FreeSqlBuilder()

View File

@ -1,23 +1,23 @@
# FreeSql # FreeSql
打造 .NETCore 最方便的ormdbfirst codefirst混合使用codefirst模式下的开发阶段建好实体不用执行任何就能创建表和修改字段dbfirst模式下提供api+模板,自定义生成代码, 打造 .NETCore 最方便的ormdbfirst codefirst混合使用codefirst模式下的开发阶段建好实体不用执行任何就能创建表和修改字段dbfirst模式下提供api+模板自定义生成代码作者提供了3种模板。
https://github.com/2881099/FreeSql/blob/master/Docs/generator.md 默认提供了3种模板。
* [Insert 插入数据](Docs/insert.md) * [Insert 插入数据](Docs/insert.md)、[Update 更新数据](Docs/update.md)、[Delete 删除数据](Docs/delete.md)、 [Select 查询数据](Docs/select.md)
* [Update 更新数据](Docs/update.md)
* [Delete 删除数据](Docs/delete.md)
* [Select 查询数据](Docs/select.md)
* [Expression 表达式函数](Docs/expression.md) * [Expression 表达式函数](Docs/expression.md)
* [CodeFirst 快速开发](Docs/codefirst.md)
* [DbFirst 快速开发](Docs/dbfirst.md) * [CodeFirst 快速开发](Docs/codefirst.md)、 [DbFirst 快速开发](Docs/dbfirst.md)、 [DbFirst 生成器](Docs/generator.md)
* [DbFirst 生成器](Docs/generator.md)
# 查询数据 # 查询数据
```csharp ```csharp
IFreeSql fsql = new FreeSql.FreeSqlBuilder() IFreeSql fsql = new FreeSql.FreeSqlBuilder()
.UseConnectionString(FreeSql.DataType.MySql, "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;Max pool size=10") .UseConnectionString(FreeSql.DataType.MySql, "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;Max pool size=10")
.UseSlave("connectionString1", "connectionString2") //使用从数据库,支持多个
.UseLogger(null) //使用日志,不指定默认输出控制台 ILogger
.UseCache(null) //使用缓存,不指定默认使用内存 IDistributedCache
.UseAutoSyncStructure(true) //自动同步实体结构到数据库
.UseSyncStructureToLower(true) //转小写同步结构
.Build(); .Build();
ISelect<Topic> select => fsql.Select<Topic>(); ISelect<Topic> select => fsql.Select<Topic>();
@ -40,8 +40,6 @@ class TestTypeInfo {
class TestTypeParentInfo { class TestTypeParentInfo {
public int Id { get; set; } public int Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
public List<TestTypeInfo> Types { get; set; }
} }
``` ```