Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
IoTSharp
IoTSharp
提交
fed32198
IoTSharp
项目概览
IoTSharp
/
IoTSharp
9 个月 前同步成功
通知
15
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
IoTSharp
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
fed32198
编写于
2月 15, 2021
作者:
麦壳饼
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mysql is working .
上级
296fed88
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
123 addition
and
71 deletion
+123
-71
IoTSharp.Data.MySQL/IoTSharpDataBuilderExtensions.cs
IoTSharp.Data.MySQL/IoTSharpDataBuilderExtensions.cs
+3
-1
IoTSharp.Data.MySQL/Migrations/20210215021817_MySqlFirstSchema.Designer.cs
...QL/Migrations/20210215021817_MySqlFirstSchema.Designer.cs
+12
-12
IoTSharp.Data.MySQL/Migrations/20210215021817_MySqlFirstSchema.cs
....Data.MySQL/Migrations/20210215021817_MySqlFirstSchema.cs
+11
-11
IoTSharp.Data.MySQL/Migrations/ApplicationDbContextModelSnapshot.cs
...ata.MySQL/Migrations/ApplicationDbContextModelSnapshot.cs
+10
-10
IoTSharp.Data.MySQL/MySqlModelBuilderOptions.cs
IoTSharp.Data.MySQL/MySqlModelBuilderOptions.cs
+51
-24
IoTSharp.Data.PostgreSQL/NpgsqlModelBuilderOptions.cs
IoTSharp.Data.PostgreSQL/NpgsqlModelBuilderOptions.cs
+27
-7
IoTSharp.Data/ApplicationDbContext.cs
IoTSharp.Data/ApplicationDbContext.cs
+3
-2
IoTSharp.Data/DataStorage.cs
IoTSharp.Data/DataStorage.cs
+2
-2
IoTSharp.Data/IDataBaseModelBuilderOptions.cs
IoTSharp.Data/IDataBaseModelBuilderOptions.cs
+2
-0
IoTSharp.Data/TelemetryData.cs
IoTSharp.Data/TelemetryData.cs
+2
-2
未找到文件。
IoTSharp.Data.MySQL/IoTSharpDataBuilderExtensions.cs
浏览文件 @
fed32198
...
...
@@ -14,10 +14,12 @@ namespace Microsoft.Extensions.DependencyInjection
{
services
.
AddEntityFrameworkMySql
();
services
.
AddSingleton
<
IDataBaseModelBuilderOptions
>(
c
=>
new
MySqlModelBuilderOptions
());
var
sv
=
ServerVersion
.
AutoDetect
(
connectionString
);
services
.
AddSingleton
(
sv
);
services
.
AddDbContextPool
<
ApplicationDbContext
>(
builder
=>
{
builder
.
UseInternalServiceProvider
(
services
.
BuildServiceProvider
());
builder
.
UseMySql
(
connectionString
,
ServerVersion
.
AutoDetect
(
connectionString
)
,
s
=>
s
.
MigrationsAssembly
(
"IoTSharp.Data.MySQL"
));
builder
.
UseMySql
(
connectionString
,
sv
,
s
=>
s
.
MigrationsAssembly
(
"IoTSharp.Data.MySQL"
));
}
,
poolSize
);
...
...
IoTSharp.Data.MySQL/Migrations/2021021
4193940_MySQL
FirstSchema.Designer.cs
→
IoTSharp.Data.MySQL/Migrations/2021021
5021817_MySql
FirstSchema.Designer.cs
浏览文件 @
fed32198
...
...
@@ -9,8 +9,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace
IoTSharp.Data.MySQL.Migrations
{
[
DbContext
(
typeof
(
ApplicationDbContext
))]
[
Migration
(
"2021021
4193940_MySQL
FirstSchema"
)]
partial
class
MyS
QL
FirstSchema
[
Migration
(
"2021021
5021817_MySql
FirstSchema"
)]
partial
class
MyS
ql
FirstSchema
{
protected
override
void
BuildTargetModel
(
ModelBuilder
modelBuilder
)
{
...
...
@@ -26,16 +26,16 @@ namespace IoTSharp.Data.MySQL.Migrations
.
HasColumnType
(
"char(36)"
);
b
.
Property
<
string
>(
"ActionData"
)
.
HasColumnType
(
"
longtext CHARACTER SET utf8mb4
"
);
.
HasColumnType
(
"
JSON
"
);
b
.
Property
<
string
>(
"ActionName"
)
.
HasColumnType
(
"longtext CHARACTER SET utf8mb4"
);
b
.
Property
<
string
>(
"ActionResult"
)
.
HasColumnType
(
"
longtext CHARACTER SET utf8mb4
"
);
.
HasColumnType
(
"
JSON
"
);
b
.
Property
<
DateTime
>(
"ActiveDateTime"
)
.
HasColumnType
(
"
datetime(6)
"
);
.
HasColumnType
(
"
timestamp
"
);
b
.
Property
<
Guid
?>(
"CustomerId"
)
.
HasColumnType
(
"char(36)"
);
...
...
@@ -152,7 +152,7 @@ namespace IoTSharp.Data.MySQL.Migrations
.
HasColumnType
(
"int"
);
b
.
Property
<
DateTime
>(
"DateTime"
)
.
HasColumnType
(
"timestamp
with time zone(6)
"
);
.
HasColumnType
(
"timestamp"
);
b
.
Property
<
int
>(
"Type"
)
.
HasColumnType
(
"int"
);
...
...
@@ -164,13 +164,13 @@ namespace IoTSharp.Data.MySQL.Migrations
.
HasColumnType
(
"tinyint(1)"
);
b
.
Property
<
DateTime
>(
"Value_DateTime"
)
.
HasColumnType
(
"timestamp
with time zone(6)
"
);
.
HasColumnType
(
"timestamp"
);
b
.
Property
<
double
>(
"Value_Double"
)
.
HasColumnType
(
"double"
);
b
.
Property
<
string
>(
"Value_Json"
)
.
HasColumnType
(
"
longtext CHARACTER SET utf8mb4
"
);
.
HasColumnType
(
"
JSON
"
);
b
.
Property
<
long
>(
"Value_Long"
)
.
HasColumnType
(
"bigint"
);
...
...
@@ -208,7 +208,7 @@ namespace IoTSharp.Data.MySQL.Migrations
.
HasColumnType
(
"int"
);
b
.
Property
<
DateTime
>(
"LastActive"
)
.
HasColumnType
(
"
datetime(6)
"
);
.
HasColumnType
(
"
timestamp
"
);
b
.
Property
<
string
>(
"Name"
)
.
HasColumnType
(
"longtext CHARACTER SET utf8mb4"
);
...
...
@@ -301,7 +301,7 @@ namespace IoTSharp.Data.MySQL.Migrations
.
HasColumnType
(
"varchar(255) CHARACTER SET utf8mb4"
);
b
.
Property
<
DateTime
>(
"DateTime"
)
.
HasColumnType
(
"timestamp
with time zone(6)
"
);
.
HasColumnType
(
"timestamp"
);
b
.
Property
<
int
>(
"DataSide"
)
.
HasColumnType
(
"int"
);
...
...
@@ -316,13 +316,13 @@ namespace IoTSharp.Data.MySQL.Migrations
.
HasColumnType
(
"tinyint(1)"
);
b
.
Property
<
DateTime
>(
"Value_DateTime"
)
.
HasColumnType
(
"timestamp
with time zone(6)
"
);
.
HasColumnType
(
"timestamp"
);
b
.
Property
<
double
>(
"Value_Double"
)
.
HasColumnType
(
"double"
);
b
.
Property
<
string
>(
"Value_Json"
)
.
HasColumnType
(
"
longtext CHARACTER SET utf8mb4
"
);
.
HasColumnType
(
"
JSON
"
);
b
.
Property
<
long
>(
"Value_Long"
)
.
HasColumnType
(
"bigint"
);
...
...
IoTSharp.Data.MySQL/Migrations/2021021
4193940_MySQL
FirstSchema.cs
→
IoTSharp.Data.MySQL/Migrations/2021021
5021817_MySql
FirstSchema.cs
浏览文件 @
fed32198
...
...
@@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
namespace
IoTSharp.Data.MySQL.Migrations
{
public
partial
class
MyS
QL
FirstSchema
:
Migration
public
partial
class
MyS
ql
FirstSchema
:
Migration
{
protected
override
void
Up
(
MigrationBuilder
migrationBuilder
)
{
...
...
@@ -54,15 +54,15 @@ namespace IoTSharp.Data.MySQL.Migrations
Catalog
=
table
.
Column
<
int
>(
type
:
"int"
,
nullable
:
false
),
DeviceId
=
table
.
Column
<
Guid
>(
type
:
"char(36)"
,
nullable
:
false
),
KeyName
=
table
.
Column
<
string
>(
type
:
"varchar(255) CHARACTER SET utf8mb4"
,
nullable
:
false
),
DateTime
=
table
.
Column
<
DateTime
>(
type
:
"timestamp
with time zone(6)
"
,
nullable
:
false
),
DateTime
=
table
.
Column
<
DateTime
>(
type
:
"timestamp"
,
nullable
:
false
),
DataSide
=
table
.
Column
<
int
>(
type
:
"int"
,
nullable
:
false
),
Type
=
table
.
Column
<
int
>(
type
:
"int"
,
nullable
:
false
),
Value_Boolean
=
table
.
Column
<
bool
>(
type
:
"tinyint(1)"
,
nullable
:
false
),
Value_String
=
table
.
Column
<
string
>(
type
:
"longtext CHARACTER SET utf8mb4"
,
nullable
:
true
),
Value_Long
=
table
.
Column
<
long
>(
type
:
"bigint"
,
nullable
:
false
),
Value_DateTime
=
table
.
Column
<
DateTime
>(
type
:
"timestamp
with time zone(6)
"
,
nullable
:
false
),
Value_DateTime
=
table
.
Column
<
DateTime
>(
type
:
"timestamp"
,
nullable
:
false
),
Value_Double
=
table
.
Column
<
double
>(
type
:
"double"
,
nullable
:
false
),
Value_Json
=
table
.
Column
<
string
>(
type
:
"
longtext CHARACTER SET utf8mb4
"
,
nullable
:
true
),
Value_Json
=
table
.
Column
<
string
>(
type
:
"
JSON
"
,
nullable
:
true
),
Value_XML
=
table
.
Column
<
string
>(
type
:
"longtext CHARACTER SET utf8mb4"
,
nullable
:
true
),
Value_Binary
=
table
.
Column
<
byte
[
]>
(
type
:
"longblob"
,
nullable
:
true
)
},
...
...
@@ -75,7 +75,7 @@ namespace IoTSharp.Data.MySQL.Migrations
name
:
"TelemetryData"
,
columns
:
table
=>
new
{
DateTime
=
table
.
Column
<
DateTime
>(
type
:
"timestamp
with time zone(6)
"
,
nullable
:
false
),
DateTime
=
table
.
Column
<
DateTime
>(
type
:
"timestamp"
,
nullable
:
false
),
DeviceId
=
table
.
Column
<
Guid
>(
type
:
"char(36)"
,
nullable
:
false
),
KeyName
=
table
.
Column
<
string
>(
type
:
"varchar(255) CHARACTER SET utf8mb4"
,
nullable
:
false
),
DataSide
=
table
.
Column
<
int
>(
type
:
"int"
,
nullable
:
false
),
...
...
@@ -83,9 +83,9 @@ namespace IoTSharp.Data.MySQL.Migrations
Value_Boolean
=
table
.
Column
<
bool
>(
type
:
"tinyint(1)"
,
nullable
:
false
),
Value_String
=
table
.
Column
<
string
>(
type
:
"longtext CHARACTER SET utf8mb4"
,
nullable
:
true
),
Value_Long
=
table
.
Column
<
long
>(
type
:
"bigint"
,
nullable
:
false
),
Value_DateTime
=
table
.
Column
<
DateTime
>(
type
:
"timestamp
with time zone(6)
"
,
nullable
:
false
),
Value_DateTime
=
table
.
Column
<
DateTime
>(
type
:
"timestamp"
,
nullable
:
false
),
Value_Double
=
table
.
Column
<
double
>(
type
:
"double"
,
nullable
:
false
),
Value_Json
=
table
.
Column
<
string
>(
type
:
"
longtext CHARACTER SET utf8mb4
"
,
nullable
:
true
),
Value_Json
=
table
.
Column
<
string
>(
type
:
"
JSON
"
,
nullable
:
true
),
Value_XML
=
table
.
Column
<
string
>(
type
:
"longtext CHARACTER SET utf8mb4"
,
nullable
:
true
),
Value_Binary
=
table
.
Column
<
byte
[
]>
(
type
:
"longblob"
,
nullable
:
true
)
},
...
...
@@ -260,9 +260,9 @@ namespace IoTSharp.Data.MySQL.Migrations
ObjectName
=
table
.
Column
<
string
>(
type
:
"longtext CHARACTER SET utf8mb4"
,
nullable
:
true
),
ObjectType
=
table
.
Column
<
int
>(
type
:
"int"
,
nullable
:
false
),
ActionName
=
table
.
Column
<
string
>(
type
:
"longtext CHARACTER SET utf8mb4"
,
nullable
:
true
),
ActionData
=
table
.
Column
<
string
>(
type
:
"
longtext CHARACTER SET utf8mb4
"
,
nullable
:
true
),
ActionResult
=
table
.
Column
<
string
>(
type
:
"
longtext CHARACTER SET utf8mb4
"
,
nullable
:
true
),
ActiveDateTime
=
table
.
Column
<
DateTime
>(
type
:
"
datetime(6)
"
,
nullable
:
false
)
ActionData
=
table
.
Column
<
string
>(
type
:
"
JSON
"
,
nullable
:
true
),
ActionResult
=
table
.
Column
<
string
>(
type
:
"
JSON
"
,
nullable
:
true
),
ActiveDateTime
=
table
.
Column
<
DateTime
>(
type
:
"
timestamp
"
,
nullable
:
false
)
},
constraints
:
table
=>
{
...
...
@@ -348,7 +348,7 @@ namespace IoTSharp.Data.MySQL.Migrations
Name
=
table
.
Column
<
string
>(
type
:
"longtext CHARACTER SET utf8mb4"
,
nullable
:
true
),
DeviceType
=
table
.
Column
<
int
>(
type
:
"int"
,
nullable
:
false
),
Online
=
table
.
Column
<
bool
>(
type
:
"tinyint(1)"
,
nullable
:
false
),
LastActive
=
table
.
Column
<
DateTime
>(
type
:
"
datetime(6)
"
,
nullable
:
false
),
LastActive
=
table
.
Column
<
DateTime
>(
type
:
"
timestamp
"
,
nullable
:
false
),
Timeout
=
table
.
Column
<
int
>(
type
:
"int"
,
nullable
:
false
),
OwnerId
=
table
.
Column
<
Guid
>(
type
:
"char(36)"
,
nullable
:
true
),
TenantId
=
table
.
Column
<
Guid
>(
type
:
"char(36)"
,
nullable
:
true
),
...
...
IoTSharp.Data.MySQL/Migrations/ApplicationDbContextModelSnapshot.cs
浏览文件 @
fed32198
...
...
@@ -24,16 +24,16 @@ namespace IoTSharp.Data.MySQL.Migrations
.
HasColumnType
(
"char(36)"
);
b
.
Property
<
string
>(
"ActionData"
)
.
HasColumnType
(
"
longtext CHARACTER SET utf8mb4
"
);
.
HasColumnType
(
"
JSON
"
);
b
.
Property
<
string
>(
"ActionName"
)
.
HasColumnType
(
"longtext CHARACTER SET utf8mb4"
);
b
.
Property
<
string
>(
"ActionResult"
)
.
HasColumnType
(
"
longtext CHARACTER SET utf8mb4
"
);
.
HasColumnType
(
"
JSON
"
);
b
.
Property
<
DateTime
>(
"ActiveDateTime"
)
.
HasColumnType
(
"
datetime(6)
"
);
.
HasColumnType
(
"
timestamp
"
);
b
.
Property
<
Guid
?>(
"CustomerId"
)
.
HasColumnType
(
"char(36)"
);
...
...
@@ -150,7 +150,7 @@ namespace IoTSharp.Data.MySQL.Migrations
.
HasColumnType
(
"int"
);
b
.
Property
<
DateTime
>(
"DateTime"
)
.
HasColumnType
(
"timestamp
with time zone(6)
"
);
.
HasColumnType
(
"timestamp"
);
b
.
Property
<
int
>(
"Type"
)
.
HasColumnType
(
"int"
);
...
...
@@ -162,13 +162,13 @@ namespace IoTSharp.Data.MySQL.Migrations
.
HasColumnType
(
"tinyint(1)"
);
b
.
Property
<
DateTime
>(
"Value_DateTime"
)
.
HasColumnType
(
"timestamp
with time zone(6)
"
);
.
HasColumnType
(
"timestamp"
);
b
.
Property
<
double
>(
"Value_Double"
)
.
HasColumnType
(
"double"
);
b
.
Property
<
string
>(
"Value_Json"
)
.
HasColumnType
(
"
longtext CHARACTER SET utf8mb4
"
);
.
HasColumnType
(
"
JSON
"
);
b
.
Property
<
long
>(
"Value_Long"
)
.
HasColumnType
(
"bigint"
);
...
...
@@ -206,7 +206,7 @@ namespace IoTSharp.Data.MySQL.Migrations
.
HasColumnType
(
"int"
);
b
.
Property
<
DateTime
>(
"LastActive"
)
.
HasColumnType
(
"
datetime(6)
"
);
.
HasColumnType
(
"
timestamp
"
);
b
.
Property
<
string
>(
"Name"
)
.
HasColumnType
(
"longtext CHARACTER SET utf8mb4"
);
...
...
@@ -299,7 +299,7 @@ namespace IoTSharp.Data.MySQL.Migrations
.
HasColumnType
(
"varchar(255) CHARACTER SET utf8mb4"
);
b
.
Property
<
DateTime
>(
"DateTime"
)
.
HasColumnType
(
"timestamp
with time zone(6)
"
);
.
HasColumnType
(
"timestamp"
);
b
.
Property
<
int
>(
"DataSide"
)
.
HasColumnType
(
"int"
);
...
...
@@ -314,13 +314,13 @@ namespace IoTSharp.Data.MySQL.Migrations
.
HasColumnType
(
"tinyint(1)"
);
b
.
Property
<
DateTime
>(
"Value_DateTime"
)
.
HasColumnType
(
"timestamp
with time zone(6)
"
);
.
HasColumnType
(
"timestamp"
);
b
.
Property
<
double
>(
"Value_Double"
)
.
HasColumnType
(
"double"
);
b
.
Property
<
string
>(
"Value_Json"
)
.
HasColumnType
(
"
longtext CHARACTER SET utf8mb4
"
);
.
HasColumnType
(
"
JSON
"
);
b
.
Property
<
long
>(
"Value_Long"
)
.
HasColumnType
(
"bigint"
);
...
...
IoTSharp.Data.MySQL/MySqlModelBuilderOptions.cs
浏览文件 @
fed32198
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore.Infrastructure
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
...
...
@@ -13,40 +14,66 @@ namespace IoTSharp.Data.MySQL
{
}
public
IInfrastructure
<
IServiceProvider
>
Infrastructure
{
get
;
set
;
}
public
void
OnModelCreating
(
ModelBuilder
modelBuilder
)
{
//modelBuilder.Entity<TelemetryData>()
//.Property(b => b.Value_Json)
//.HasColumnType("jsonb");
var
sv
=
Infrastructure
.
GetService
<
ServerVersion
>();
modelBuilder
.
Entity
<
TelemetryData
>()
.
Property
(
b
=>
b
.
DateTime
)
.
HasColumnType
(
"timestamp"
);
modelBuilder
.
Entity
<
TelemetryData
>()
.
Property
(
b
=>
b
.
Value_DateTime
)
.
HasColumnType
(
"timestamp"
);
//modelBuilder.Entity<TelemetryData>()
//.Property(b => b.Value_XML)
//.HasColumnType("xml");
//modelBuilder.Entity<AttributeLatest>()
//.Property(b => b.Value_Json)
//.HasColumnType("jsonb");
modelBuilder
.
Entity
<
TelemetryLatest
>()
.
Property
(
b
=>
b
.
DateTime
)
.
HasColumnType
(
"timestamp"
);
modelBuilder
.
Entity
<
TelemetryLatest
>()
.
Property
(
b
=>
b
.
Value_DateTime
)
.
HasColumnType
(
"timestamp"
);
//modelBuilder.Entity<AttributeLatest>()
//.Property(b => b.Value_XML)
//.HasColumnType("xml");
modelBuilder
.
Entity
<
AttributeLatest
>()
.
Property
(
b
=>
b
.
DateTime
)
.
HasColumnType
(
"timestamp"
);
modelBuilder
.
Entity
<
AttributeLatest
>()
.
Property
(
b
=>
b
.
Value_DateTime
)
.
HasColumnType
(
"timestamp"
);
modelBuilder
.
Entity
<
AuditLog
>()
.
Property
(
b
=>
b
.
ActiveDateTime
)
.
HasColumnType
(
"timestamp"
);
modelBuilder
.
Entity
<
Device
>()
.
Property
(
b
=>
b
.
LastActive
)
.
HasColumnType
(
"timestamp"
);
if
(
sv
.
Supports
.
Json
)
{
modelBuilder
.
Entity
<
TelemetryData
>()
.
Property
(
b
=>
b
.
Value_Json
)
.
HasColumnType
(
"JSON"
);
modelBuilder
.
Entity
<
TelemetryData
>()
.
Property
(
b
=>
b
.
Value_Json
)
.
HasColumnType
(
"JSON"
);
//modelBuilder.Entity<Telemetry
Latest>()
//
.Property(b => b.Value_Json)
//.HasColumnType("jsonb
");
modelBuilder
.
Entity
<
Attribute
Latest
>()
.
Property
(
b
=>
b
.
Value_Json
)
.
HasColumnType
(
"JSON
"
);
//
modelBuilder.Entity<TelemetryLatest>()
//.Property(b => b.Value_XML
)
//.HasColumnType("xml
");
modelBuilder
.
Entity
<
TelemetryLatest
>()
.
Property
(
b
=>
b
.
Value_Json
)
.
HasColumnType
(
"JSON
"
);
//
modelBuilder.Entity<AuditLog>()
//
.Property(b => b.ActionData)
//.HasColumnType("jsonb
");
modelBuilder
.
Entity
<
AuditLog
>()
.
Property
(
b
=>
b
.
ActionData
)
.
HasColumnType
(
"JSON
"
);
//modelBuilder.Entity<AuditLog>()
//.Property(b => b.ActionResult)
//.HasColumnType("jsonb");
modelBuilder
.
Entity
<
AuditLog
>()
.
Property
(
b
=>
b
.
ActionResult
)
.
HasColumnType
(
"JSON"
);
}
}
}
}
IoTSharp.Data.PostgreSQL/NpgsqlModelBuilderOptions.cs
浏览文件 @
fed32198
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore.Infrastructure
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
IoTSharp.Data.PostgreSQL
{
...
...
@@ -11,10 +8,34 @@ namespace IoTSharp.Data.PostgreSQL
{
public
NpgsqlModelBuilderOptions
()
{
}
public
IInfrastructure
<
IServiceProvider
>
Infrastructure
{
get
;
set
;
}
public
void
OnModelCreating
(
ModelBuilder
modelBuilder
)
{
modelBuilder
.
Entity
<
TelemetryData
>()
.
Property
(
b
=>
b
.
DateTime
)
.
HasColumnType
(
"timestamp with time zone"
);
modelBuilder
.
Entity
<
TelemetryData
>()
.
Property
(
b
=>
b
.
Value_DateTime
)
.
HasColumnType
(
"timestamp with time zone"
);
modelBuilder
.
Entity
<
TelemetryLatest
>()
.
Property
(
b
=>
b
.
DateTime
)
.
HasColumnType
(
"timestamp with time zone"
);
modelBuilder
.
Entity
<
TelemetryLatest
>()
.
Property
(
b
=>
b
.
Value_DateTime
)
.
HasColumnType
(
"timestamp with time zone"
);
modelBuilder
.
Entity
<
AttributeLatest
>()
.
Property
(
b
=>
b
.
DateTime
)
.
HasColumnType
(
"timestamp with time zone"
);
modelBuilder
.
Entity
<
AttributeLatest
>()
.
Property
(
b
=>
b
.
Value_DateTime
)
.
HasColumnType
(
"timestamp with time zone"
);
modelBuilder
.
Entity
<
TelemetryData
>()
.
Property
(
b
=>
b
.
Value_Json
)
.
HasColumnType
(
"jsonb"
);
...
...
@@ -31,7 +52,6 @@ namespace IoTSharp.Data.PostgreSQL
.
Property
(
b
=>
b
.
Value_XML
)
.
HasColumnType
(
"xml"
);
modelBuilder
.
Entity
<
TelemetryLatest
>()
.
Property
(
b
=>
b
.
Value_Json
)
.
HasColumnType
(
"jsonb"
);
...
...
@@ -49,4 +69,4 @@ namespace IoTSharp.Data.PostgreSQL
.
HasColumnType
(
"jsonb"
);
}
}
}
}
\ No newline at end of file
IoTSharp.Data/ApplicationDbContext.cs
浏览文件 @
fed32198
...
...
@@ -16,7 +16,6 @@ namespace IoTSharp.Data
public
ApplicationDbContext
(
DbContextOptions
<
ApplicationDbContext
>
options
)
:
base
(
options
)
{
if
(
Database
.
GetPendingMigrations
().
Count
()
>
0
)
{
Database
.
Migrate
();
...
...
@@ -42,7 +41,9 @@ namespace IoTSharp.Data
modelBuilder
.
Entity
<
TelemetryLatest
>().
HasDiscriminator
<
DataCatalog
>(
nameof
(
Data
.
DataStorage
.
Catalog
));
modelBuilder
.
Entity
<
Device
>().
HasDiscriminator
<
DeviceType
>(
nameof
(
Data
.
Device
.
DeviceType
)).
HasValue
<
Gateway
>(
DeviceType
.
Gateway
).
HasValue
<
Device
>(
DeviceType
.
Device
);
modelBuilder
.
Entity
<
Gateway
>().
HasDiscriminator
<
DeviceType
>(
nameof
(
Data
.
Device
.
DeviceType
));
this
.
GetService
<
IDataBaseModelBuilderOptions
>().
OnModelCreating
(
modelBuilder
);
var
builder_options
=
this
.
GetService
<
IDataBaseModelBuilderOptions
>();
builder_options
.
Infrastructure
=
this
;
builder_options
.
OnModelCreating
(
modelBuilder
);
modelBuilder
.
ApplyConfiguration
(
new
TelemetryDataConfiguration
());
base
.
OnModelCreating
(
modelBuilder
);
}
...
...
IoTSharp.Data/DataStorage.cs
浏览文件 @
fed32198
...
...
@@ -36,7 +36,7 @@ namespace IoTSharp.Data
[
Column
(
Order
=
2
)]
public
string
KeyName
{
get
;
set
;
}
[
Column
(
Order
=
3
,
TypeName
=
"timestamp with time zone"
)]
[
Column
(
Order
=
3
)]
public
DateTime
DateTime
{
get
;
set
;
}
[
Column
(
Order
=
4
)]
...
...
@@ -50,7 +50,7 @@ namespace IoTSharp.Data
public
bool
Value_Boolean
{
get
;
set
;
}
public
string
Value_String
{
get
;
set
;
}
public
long
Value_Long
{
get
;
set
;
}
[
Column
(
TypeName
=
"timestamp with time zone"
)]
public
DateTime
Value_DateTime
{
get
;
set
;
}
public
double
Value_Double
{
get
;
set
;
}
public
string
Value_Json
{
get
;
set
;
}
...
...
IoTSharp.Data/IDataBaseModelBuilderOptions.cs
浏览文件 @
fed32198
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore.Infrastructure
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
...
...
@@ -9,6 +10,7 @@ namespace IoTSharp.Data
{
public
interface
IDataBaseModelBuilderOptions
{
public
IInfrastructure
<
IServiceProvider
>
Infrastructure
{
get
;
set
;
}
public
void
OnModelCreating
(
ModelBuilder
modelBuilder
);
}
}
IoTSharp.Data/TelemetryData.cs
浏览文件 @
fed32198
...
...
@@ -16,7 +16,7 @@ namespace IoTSharp.Data
[
Column
(
Order
=
2
)]
public
string
KeyName
{
get
;
set
;
}
[
Column
(
Order
=
3
,
TypeName
=
"timestamp with time zone"
)]
[
Column
(
Order
=
3
)]
public
DateTime
DateTime
{
get
;
set
;
}
[
Column
(
Order
=
4
)]
...
...
@@ -30,7 +30,7 @@ namespace IoTSharp.Data
public
bool
Value_Boolean
{
get
;
set
;
}
public
string
Value_String
{
get
;
set
;
}
public
long
Value_Long
{
get
;
set
;
}
[
Column
(
TypeName
=
"timestamp with time zone"
)]
public
DateTime
Value_DateTime
{
get
;
set
;
}
public
double
Value_Double
{
get
;
set
;
}
public
string
Value_Json
{
get
;
set
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录