提交 b073961a 编写于 作者: S sam 提交者: Yanhong.Ma

修正sqlite大小写问题。

上级 b4197a7d
......@@ -5,6 +5,7 @@ using IoTSharp.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Linq;
namespace Microsoft.Extensions.DependencyInjection
{
......@@ -32,5 +33,17 @@ namespace Microsoft.Extensions.DependencyInjection
builder.AddDataSource(connectionString, ReadWriteType.Read | ReadWriteType.Write, DatabaseType.SQLite);
builder.SetDateSharding<TelemetryData>(nameof(TelemetryData.DateTime), expandBy, DateTime.Now);
}
public static void SetCaseInsensitiveSearchesForSQLite(this ModelBuilder modelBuilder)
{
modelBuilder.UseCollation("NOCASE");
foreach (var property in modelBuilder.Model.GetEntityTypes()
.SelectMany(t => t.GetProperties())
.Where(p => p.ClrType == typeof(string)))
{
property.SetCollation("NOCASE");
}
}
}
}
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using System;
using Microsoft.Extensions.DependencyInjection;
namespace IoTSharp.Data.Sqlite
{
......@@ -14,7 +15,7 @@ namespace IoTSharp.Data.Sqlite
public void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.SetCaseInsensitiveSearchesForSQLite();
}
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册