mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 02:32:50 +08:00
v0.9.13
- 增加 FreeSql.Extensions.JsonMap 扩展包,实现快速将对象映射为json字符串的方法; - 优化 表达式解析未实现的错误提醒,如 $"";
This commit is contained in:
parent
8520008b82
commit
62a095df8f
@ -1,17 +1,48 @@
|
|||||||
using FreeSql;
|
using FreeSql;
|
||||||
|
using FreeSql.DataAnnotations;
|
||||||
|
using FreeSql.Extensions;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Linq.Expressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace base_entity
|
namespace base_entity
|
||||||
{
|
{
|
||||||
class Program
|
class Program
|
||||||
{
|
{
|
||||||
|
class TestConfig
|
||||||
|
{
|
||||||
|
public int clicks { get; set; }
|
||||||
|
public string title { get; set; }
|
||||||
|
}
|
||||||
|
[Table(Name = "sysconfig")]
|
||||||
|
public class S_SysConfig<T> : BaseEntity<S_SysConfig<T>>
|
||||||
|
{
|
||||||
|
[Column(IsPrimary = true)]
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
[JsonMap]
|
||||||
|
public T Config { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
|
#region 初始化 IFreeSql
|
||||||
BaseEntity.Initialization(new FreeSql.FreeSqlBuilder()
|
BaseEntity.Initialization(new FreeSql.FreeSqlBuilder()
|
||||||
.UseAutoSyncStructure(true)
|
.UseAutoSyncStructure(true)
|
||||||
|
.UseNoneCommandParameter(true)
|
||||||
.UseConnectionString(FreeSql.DataType.Sqlite, "data source=test.db;max pool size=5")
|
.UseConnectionString(FreeSql.DataType.Sqlite, "data source=test.db;max pool size=5")
|
||||||
|
.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=2")
|
||||||
.Build());
|
.Build());
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
BaseEntity.Orm.UseJsonMap();
|
||||||
|
|
||||||
|
new S_SysConfig<TestConfig> { Name = "testkey11", Config = new TestConfig { clicks = 11, title = "testtitle11" } }.Save();
|
||||||
|
new S_SysConfig<TestConfig> { Name = "testkey22", Config = new TestConfig { clicks = 22, title = "testtitle22" } }.Save();
|
||||||
|
new S_SysConfig<TestConfig> { Name = "testkey33", Config = new TestConfig { clicks = 33, title = "testtitle33" } }.Save();
|
||||||
|
var testconfigs11 = S_SysConfig<TestConfig>.Select.ToList();
|
||||||
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\Extensions\FreeSql.Extensions.BaseEntity\FreeSql.Extensions.BaseEntity.csproj" />
|
<ProjectReference Include="..\..\Extensions\FreeSql.Extensions.BaseEntity\FreeSql.Extensions.BaseEntity.csproj" />
|
||||||
|
<ProjectReference Include="..\..\Extensions\FreeSql.Extensions.JsonMap\FreeSql.Extensions.JsonMap.csproj" />
|
||||||
<ProjectReference Include="..\..\FreeSql.Repository\FreeSql.Repository.csproj" />
|
<ProjectReference Include="..\..\FreeSql.Repository\FreeSql.Repository.csproj" />
|
||||||
<ProjectReference Include="..\..\FreeSql\FreeSql.csproj" />
|
<ProjectReference Include="..\..\FreeSql\FreeSql.csproj" />
|
||||||
<ProjectReference Include="..\..\Providers\FreeSql.Provider.MySql\FreeSql.Provider.MySql.csproj" />
|
<ProjectReference Include="..\..\Providers\FreeSql.Provider.MySql\FreeSql.Provider.MySql.csproj" />
|
||||||
|
@ -43,7 +43,7 @@ namespace FreeSql
|
|||||||
/// 创建时间
|
/// 创建时间
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Column(Position = -4)]
|
[Column(Position = -4)]
|
||||||
public DateTime CreateTime { get; set; }
|
public DateTime CreateTime { get; set; } = DateTime.Now;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 更新时间
|
/// 更新时间
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0</TargetFrameworks>
|
||||||
<Version>0.9.12</Version>
|
<Version>0.9.15</Version>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<Authors>YeXiangQin</Authors>
|
<Authors>YeXiangQin</Authors>
|
||||||
<Description>BaseEntity 是一种极简单的 CodeFirst 开发方式,特别对单表或多表CRUD,利用继承节省了每个实体类的重复属性(创建时间、ID等字段),软件删除等功能,进行 crud 操作时不必时常考虑仓储的使用.</Description>
|
<Description>BaseEntity 是一种极简单的 CodeFirst 开发方式,特别对单表或多表CRUD,利用继承节省了每个实体类的重复属性(创建时间、ID等字段),软件删除等功能,进行 crud 操作时不必时常考虑仓储的使用.</Description>
|
||||||
@ -12,6 +12,7 @@
|
|||||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||||
<PackageTags>FreeSql;ORM;BaseEntity</PackageTags>
|
<PackageTags>FreeSql;ORM;BaseEntity</PackageTags>
|
||||||
<PackageId>$(AssemblyName)</PackageId>
|
<PackageId>$(AssemblyName)</PackageId>
|
||||||
|
<PackageIconUrl>https://github.com/2881099/FreeSql/blob/master/logo.png</PackageIconUrl>
|
||||||
<Title>$(AssemblyName)</Title>
|
<Title>$(AssemblyName)</Title>
|
||||||
<IsPackable>true</IsPackable>
|
<IsPackable>true</IsPackable>
|
||||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace FreeSql.DataAnnotations
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 当实体类属性为【对象】时,以JSON形式映射存储
|
||||||
|
/// </summary>
|
||||||
|
public class JsonMapAttribute : Attribute
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
|
||||||
|
<Version>0.9.15</Version>
|
||||||
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
|
<Authors>YeXiangQin</Authors>
|
||||||
|
<Description>FreeSql 扩展包,可实现实体类属性为对象时,以JSON形式映射存储.</Description>
|
||||||
|
<PackageProjectUrl>https://github.com/2881099/FreeSql</PackageProjectUrl>
|
||||||
|
<RepositoryUrl>https://github.com/2881099/FreeSql</RepositoryUrl>
|
||||||
|
<RepositoryType>git</RepositoryType>
|
||||||
|
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||||
|
<PackageTags>FreeSql;ORM</PackageTags>
|
||||||
|
<PackageId>$(AssemblyName)</PackageId>
|
||||||
|
<PackageIconUrl>https://github.com/2881099/FreeSql/blob/master/logo.png</PackageIconUrl>
|
||||||
|
<Title>$(AssemblyName)</Title>
|
||||||
|
<IsPackable>true</IsPackable>
|
||||||
|
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\FreeSql\FreeSql.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
58
Extensions/FreeSql.Extensions.JsonMap/JsonMapCore.cs
Normal file
58
Extensions/FreeSql.Extensions.JsonMap/JsonMapCore.cs
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
using FreeSql.DataAnnotations;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace FreeSql.Extensions
|
||||||
|
{
|
||||||
|
public static class JsonMapCore
|
||||||
|
{
|
||||||
|
static bool _isAoped = false;
|
||||||
|
static object _isAopedLock = new object();
|
||||||
|
static ConcurrentDictionary<Type, bool> _dicTypes = new ConcurrentDictionary<Type, bool>();
|
||||||
|
static MethodInfo MethodJsonConvertDeserializeObject = typeof(JsonConvert).GetMethod("DeserializeObject", new[] { typeof(string), typeof(Type) });
|
||||||
|
static MethodInfo MethodJsonConvertSerializeObject = typeof(JsonConvert).GetMethod("SerializeObject", new[] { typeof(object) });
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 当实体类属性为【对象】时,并且标记特性 [JsonMap] 时,该属性将以JSON形式映射存储
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static void UseJsonMap(this IFreeSql that)
|
||||||
|
{
|
||||||
|
if (_isAoped == false)
|
||||||
|
lock(_isAopedLock)
|
||||||
|
if (_isAoped == false)
|
||||||
|
{
|
||||||
|
_isAoped = true;
|
||||||
|
|
||||||
|
FreeSql.Internal.Utils.GetDataReaderValueBlockExpressionSwitchTypeFullName.Add((LabelTarget returnTarget, Expression valueExp, Type type) =>
|
||||||
|
{
|
||||||
|
if (_dicTypes.ContainsKey(type)) return Expression.Return(returnTarget, Expression.TypeAs(Expression.Call(MethodJsonConvertDeserializeObject, Expression.Convert(valueExp, typeof(string)), Expression.Constant(type)), type));
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
|
||||||
|
that.Aop.ConfigEntityProperty += new EventHandler<Aop.ConfigEntityPropertyEventArgs>((s, e) =>
|
||||||
|
{
|
||||||
|
if (e.Property.GetCustomAttribute<JsonMapAttribute>(false) != null)
|
||||||
|
{
|
||||||
|
e.ModifyResult.MapType = typeof(string);
|
||||||
|
if (_dicTypes.TryAdd(e.Property.PropertyType, true))
|
||||||
|
{
|
||||||
|
FreeSql.Internal.Utils.GetDataReaderValueBlockExpressionObjectToStringIfThenElse.Add((LabelTarget returnTarget, Expression valueExp, Expression elseExp, Type type) =>
|
||||||
|
{
|
||||||
|
return Expression.IfThenElse(
|
||||||
|
Expression.TypeEqual(valueExp, e.Property.PropertyType),
|
||||||
|
Expression.Return(returnTarget, Expression.Call(MethodJsonConvertSerializeObject, Expression.Convert(valueExp, typeof(object))), typeof(object)),
|
||||||
|
elseExp);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
23
Extensions/FreeSql.Extensions.JsonMap/readme.md
Normal file
23
Extensions/FreeSql.Extensions.JsonMap/readme.md
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
FreeSql 扩展包,将值对象映射成 typeof(string),安装扩展包:
|
||||||
|
|
||||||
|
> dotnet add package FreeSql.Extensions.JsonMap
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
fsql.UseJsonMap(); //开启功能
|
||||||
|
|
||||||
|
class TestConfig
|
||||||
|
{
|
||||||
|
public int clicks { get; set; }
|
||||||
|
public string title { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[Table(Name = "sysconfig")]
|
||||||
|
public class S_SysConfig<T>
|
||||||
|
{
|
||||||
|
[Column(IsPrimary = true)]
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
[JsonMap]
|
||||||
|
public T Config { get; set; }
|
||||||
|
}
|
||||||
|
```
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
|
||||||
<Version>0.9.12</Version>
|
<Version>0.9.15</Version>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<Authors>YeXiangQin</Authors>
|
<Authors>YeXiangQin</Authors>
|
||||||
<Description>FreeSql 扩展包,可实现【延时加载】属性.</Description>
|
<Description>FreeSql 扩展包,可实现【延时加载】属性.</Description>
|
||||||
@ -12,6 +12,7 @@
|
|||||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||||
<PackageTags>FreeSql;ORM</PackageTags>
|
<PackageTags>FreeSql;ORM</PackageTags>
|
||||||
<PackageId>$(AssemblyName)</PackageId>
|
<PackageId>$(AssemblyName)</PackageId>
|
||||||
|
<PackageIconUrl>https://github.com/2881099/FreeSql/blob/master/logo.png</PackageIconUrl>
|
||||||
<Title>$(AssemblyName)</Title>
|
<Title>$(AssemblyName)</Title>
|
||||||
<IsPackable>true</IsPackable>
|
<IsPackable>true</IsPackable>
|
||||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
|
||||||
<Version>0.9.12</Version>
|
<Version>0.9.15</Version>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<Authors>YeXiangQin</Authors>
|
<Authors>YeXiangQin</Authors>
|
||||||
<Description>FreeSql is the most convenient ORM in dotnet. It supports Mysql, Postgresql, SqlServer, Oracle and Sqlite.</Description>
|
<Description>FreeSql is the most convenient ORM in dotnet. It supports Mysql, Postgresql, SqlServer, Oracle and Sqlite.</Description>
|
||||||
@ -11,6 +11,7 @@
|
|||||||
<RepositoryType>git</RepositoryType>
|
<RepositoryType>git</RepositoryType>
|
||||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||||
<PackageId>$(AssemblyName)</PackageId>
|
<PackageId>$(AssemblyName)</PackageId>
|
||||||
|
<PackageIconUrl>https://github.com/2881099/FreeSql/blob/master/logo.png</PackageIconUrl>
|
||||||
<Title>$(AssemblyName)</Title>
|
<Title>$(AssemblyName)</Title>
|
||||||
<IsPackable>true</IsPackable>
|
<IsPackable>true</IsPackable>
|
||||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
|
||||||
<Version>0.9.12</Version>
|
<Version>0.9.15</Version>
|
||||||
<Authors>YeXiangQin</Authors>
|
<Authors>YeXiangQin</Authors>
|
||||||
<Description>FreeSql Implementation of General Repository, Support MySql/SqlServer/PostgreSQL/Oracle/Sqlite, and read/write separation、and split table.</Description>
|
<Description>FreeSql Implementation of General Repository, Support MySql/SqlServer/PostgreSQL/Oracle/Sqlite, and read/write separation、and split table.</Description>
|
||||||
<PackageProjectUrl>https://github.com/2881099/FreeSql/wiki/Repository</PackageProjectUrl>
|
<PackageProjectUrl>https://github.com/2881099/FreeSql/wiki/Repository</PackageProjectUrl>
|
||||||
@ -11,6 +11,7 @@
|
|||||||
<RepositoryType>git</RepositoryType>
|
<RepositoryType>git</RepositoryType>
|
||||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||||
<PackageId>$(AssemblyName)</PackageId>
|
<PackageId>$(AssemblyName)</PackageId>
|
||||||
|
<PackageIconUrl>https://github.com/2881099/FreeSql/blob/master/logo.png</PackageIconUrl>
|
||||||
<Title>$(AssemblyName)</Title>
|
<Title>$(AssemblyName)</Title>
|
||||||
<IsPackable>true</IsPackable>
|
<IsPackable>true</IsPackable>
|
||||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||||
|
@ -406,6 +406,9 @@ namespace FreeSql.Tests
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void Test1()
|
public void Test1()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
var testssargs1 = "10100";
|
||||||
|
var testformatsql1 = g.mysql.Select<TaskBuild>().Where(a => a.NamespaceName == $"1_{10100}").ToSql();
|
||||||
var testorderbysql = g.mysql.Select<TaskBuild>().OrderByDescending(a => a.OptionsEntity04 + (a.score ?? 0)).ToSql();
|
var testorderbysql = g.mysql.Select<TaskBuild>().OrderByDescending(a => a.OptionsEntity04 + (a.score ?? 0)).ToSql();
|
||||||
|
|
||||||
var testincludeMemberssql1 = g.sqlite.Select<TaskBuild>().Where(a => a.Templates.Title == "1").ToList();
|
var testincludeMemberssql1 = g.sqlite.Select<TaskBuild>().Where(a => a.Templates.Title == "1").ToList();
|
||||||
|
15
FreeSql.sln
15
FreeSql.sln
@ -58,6 +58,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "base_entity", "Examples\bas
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeSql.Extensions.BaseEntity", "Extensions\FreeSql.Extensions.BaseEntity\FreeSql.Extensions.BaseEntity.csproj", "{FE0CB06E-493F-4CE8-B2D7-BF48CA8015C6}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeSql.Extensions.BaseEntity", "Extensions\FreeSql.Extensions.BaseEntity\FreeSql.Extensions.BaseEntity.csproj", "{FE0CB06E-493F-4CE8-B2D7-BF48CA8015C6}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeSql.Extensions.JsonMap", "Extensions\FreeSql.Extensions.JsonMap\FreeSql.Extensions.JsonMap.csproj", "{3043DEF1-85DF-47AD-8D5D-327270794356}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -332,6 +334,18 @@ Global
|
|||||||
{FE0CB06E-493F-4CE8-B2D7-BF48CA8015C6}.Release|x64.Build.0 = Release|Any CPU
|
{FE0CB06E-493F-4CE8-B2D7-BF48CA8015C6}.Release|x64.Build.0 = Release|Any CPU
|
||||||
{FE0CB06E-493F-4CE8-B2D7-BF48CA8015C6}.Release|x86.ActiveCfg = Release|Any CPU
|
{FE0CB06E-493F-4CE8-B2D7-BF48CA8015C6}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{FE0CB06E-493F-4CE8-B2D7-BF48CA8015C6}.Release|x86.Build.0 = Release|Any CPU
|
{FE0CB06E-493F-4CE8-B2D7-BF48CA8015C6}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{3043DEF1-85DF-47AD-8D5D-327270794356}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{3043DEF1-85DF-47AD-8D5D-327270794356}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{3043DEF1-85DF-47AD-8D5D-327270794356}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{3043DEF1-85DF-47AD-8D5D-327270794356}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{3043DEF1-85DF-47AD-8D5D-327270794356}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{3043DEF1-85DF-47AD-8D5D-327270794356}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{3043DEF1-85DF-47AD-8D5D-327270794356}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{3043DEF1-85DF-47AD-8D5D-327270794356}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{3043DEF1-85DF-47AD-8D5D-327270794356}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{3043DEF1-85DF-47AD-8D5D-327270794356}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{3043DEF1-85DF-47AD-8D5D-327270794356}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{3043DEF1-85DF-47AD-8D5D-327270794356}.Release|x86.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@ -352,6 +366,7 @@ Global
|
|||||||
{4C0973CB-BD49-4A5B-A6FE-EE0594BDD513} = {94C8A78D-AA15-47B2-A348-530CD86BFC1B}
|
{4C0973CB-BD49-4A5B-A6FE-EE0594BDD513} = {94C8A78D-AA15-47B2-A348-530CD86BFC1B}
|
||||||
{D3A1869C-A8DE-46D0-8587-89EBBE3E4DD0} = {94C8A78D-AA15-47B2-A348-530CD86BFC1B}
|
{D3A1869C-A8DE-46D0-8587-89EBBE3E4DD0} = {94C8A78D-AA15-47B2-A348-530CD86BFC1B}
|
||||||
{FE0CB06E-493F-4CE8-B2D7-BF48CA8015C6} = {4A92E8A6-9A6D-41A1-9CDA-DE10899648AA}
|
{FE0CB06E-493F-4CE8-B2D7-BF48CA8015C6} = {4A92E8A6-9A6D-41A1-9CDA-DE10899648AA}
|
||||||
|
{3043DEF1-85DF-47AD-8D5D-327270794356} = {4A92E8A6-9A6D-41A1-9CDA-DE10899648AA}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {089687FD-5D25-40AB-BA8A-A10D1E137F98}
|
SolutionGuid = {089687FD-5D25-40AB-BA8A-A10D1E137F98}
|
||||||
|
@ -77,7 +77,9 @@ namespace FreeSql.DataAnnotations
|
|||||||
public object DbDefautValue { get; internal set; }
|
public object DbDefautValue { get; internal set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 类型映射,比如:可将 enum 属性映射成 typeof(string)
|
/// 类型映射,除了可做基本的类型映射外,特别介绍的功能:<para></para>
|
||||||
|
/// 1、将 enum 属性映射成 typeof(string)<para></para>
|
||||||
|
/// 2、将 对象 属性映射成 typeof(string),请安装扩展包 FreeSql.Extensions.JsonMap
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Type MapType { get; set; }
|
public Type MapType { get; set; }
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
|
||||||
<Version>0.9.12</Version>
|
<Version>0.9.15</Version>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<Authors>YeXiangQin</Authors>
|
<Authors>YeXiangQin</Authors>
|
||||||
<Description>FreeSql is the most convenient ORM in dotnet. It supports Mysql, Postgresql, SqlServer, Oracle and Sqlite.</Description>
|
<Description>FreeSql is the most convenient ORM in dotnet. It supports Mysql, Postgresql, SqlServer, Oracle and Sqlite.</Description>
|
||||||
@ -12,6 +12,7 @@
|
|||||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||||
<PackageTags>FreeSql;ORM</PackageTags>
|
<PackageTags>FreeSql;ORM</PackageTags>
|
||||||
<PackageId>$(AssemblyName)</PackageId>
|
<PackageId>$(AssemblyName)</PackageId>
|
||||||
|
<PackageIconUrl>https://github.com/2881099/FreeSql/blob/master/logo.png</PackageIconUrl>
|
||||||
<Title>$(AssemblyName)</Title>
|
<Title>$(AssemblyName)</Title>
|
||||||
<IsPackable>true</IsPackable>
|
<IsPackable>true</IsPackable>
|
||||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||||
|
@ -57,7 +57,9 @@
|
|||||||
</member>
|
</member>
|
||||||
<member name="P:FreeSql.DataAnnotations.ColumnAttribute.MapType">
|
<member name="P:FreeSql.DataAnnotations.ColumnAttribute.MapType">
|
||||||
<summary>
|
<summary>
|
||||||
类型映射,比如:可将 enum 属性映射成 typeof(string)
|
类型映射,除了可做基本的类型映射外,特别介绍的功能:<para></para>
|
||||||
|
1、将 enum 属性映射成 typeof(string)<para></para>
|
||||||
|
2、将 对象 属性映射成 typeof(string),请安装扩展包 FreeSql.Extensions.JsonMap
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="P:FreeSql.DataAnnotations.ColumnAttribute.Position">
|
<member name="P:FreeSql.DataAnnotations.ColumnAttribute.Position">
|
||||||
|
@ -535,14 +535,16 @@ namespace FreeSql.Internal
|
|||||||
tsc.mapType = null;
|
tsc.mapType = null;
|
||||||
var exp3 = exp as MethodCallExpression;
|
var exp3 = exp as MethodCallExpression;
|
||||||
var callType = exp3.Object?.Type ?? exp3.Method.DeclaringType;
|
var callType = exp3.Object?.Type ?? exp3.Method.DeclaringType;
|
||||||
|
string other3Exp = null;
|
||||||
switch (callType.FullName)
|
switch (callType.FullName)
|
||||||
{
|
{
|
||||||
case "System.String": return ExpressionLambdaToSqlCallString(exp3, tsc);
|
case "System.String": other3Exp = ExpressionLambdaToSqlCallString(exp3, tsc); break;
|
||||||
case "System.Math": return ExpressionLambdaToSqlCallMath(exp3, tsc);
|
case "System.Math": other3Exp = ExpressionLambdaToSqlCallMath(exp3, tsc); break;
|
||||||
case "System.DateTime": return ExpressionLambdaToSqlCallDateTime(exp3, tsc);
|
case "System.DateTime": other3Exp = ExpressionLambdaToSqlCallDateTime(exp3, tsc); break;
|
||||||
case "System.TimeSpan": return ExpressionLambdaToSqlCallTimeSpan(exp3, tsc);
|
case "System.TimeSpan": other3Exp = ExpressionLambdaToSqlCallTimeSpan(exp3, tsc); break;
|
||||||
case "System.Convert": return ExpressionLambdaToSqlCallConvert(exp3, tsc);
|
case "System.Convert": other3Exp = ExpressionLambdaToSqlCallConvert(exp3, tsc); break;
|
||||||
}
|
}
|
||||||
|
if (string.IsNullOrEmpty(other3Exp) == false) return other3Exp;
|
||||||
if (exp3.Method.Name == "Equals" && exp3.Object != null && exp3.Arguments.Count > 0)
|
if (exp3.Method.Name == "Equals" && exp3.Object != null && exp3.Arguments.Count > 0)
|
||||||
return ExpressionBinary("=", exp3.Object, exp3.Arguments[0], tsc);
|
return ExpressionBinary("=", exp3.Object, exp3.Arguments[0], tsc);
|
||||||
if (callType.FullName.StartsWith("FreeSql.ISelectGroupingAggregate`"))
|
if (callType.FullName.StartsWith("FreeSql.ISelectGroupingAggregate`"))
|
||||||
@ -849,7 +851,7 @@ namespace FreeSql.Internal
|
|||||||
|
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
var other3Exp = ExpressionLambdaToSqlOther(exp3, tsc);
|
other3Exp = ExpressionLambdaToSqlOther(exp3, tsc);
|
||||||
if (string.IsNullOrEmpty(other3Exp) == false) return other3Exp;
|
if (string.IsNullOrEmpty(other3Exp) == false) return other3Exp;
|
||||||
if (exp3.IsParameter() == false) return formatSql(Expression.Lambda(exp3).Compile().DynamicInvoke(), tsc.mapType);
|
if (exp3.IsParameter() == false) return formatSql(Expression.Lambda(exp3).Compile().DynamicInvoke(), tsc.mapType);
|
||||||
throw new Exception($"未实现函数表达式 {exp3} 解析");
|
throw new Exception($"未实现函数表达式 {exp3} 解析");
|
||||||
|
@ -1466,7 +1466,8 @@ namespace FreeSql.Internal
|
|||||||
static PropertyInfo PropertyDateTimeTicks = typeof(DateTime).GetProperty("Ticks", BindingFlags.Instance | BindingFlags.Public);
|
static PropertyInfo PropertyDateTimeTicks = typeof(DateTime).GetProperty("Ticks", BindingFlags.Instance | BindingFlags.Public);
|
||||||
static ConstructorInfo CtorDateTimeOffsetArgsTicks = typeof(DateTimeOffset).GetConstructor(new[] { typeof(long), typeof(TimeSpan) });
|
static ConstructorInfo CtorDateTimeOffsetArgsTicks = typeof(DateTimeOffset).GetConstructor(new[] { typeof(long), typeof(TimeSpan) });
|
||||||
|
|
||||||
public static ConcurrentBag<Func<LabelTarget, Expression, string, Expression>> GetDataReaderValueBlockExpressionSwitchTypeFullName = new ConcurrentBag<Func<LabelTarget, Expression, string, Expression>>();
|
public static ConcurrentBag<Func<LabelTarget, Expression, Type, Expression>> GetDataReaderValueBlockExpressionSwitchTypeFullName = new ConcurrentBag<Func<LabelTarget, Expression, Type, Expression>>();
|
||||||
|
public static ConcurrentBag<Func<LabelTarget, Expression, Expression, Type, Expression>> GetDataReaderValueBlockExpressionObjectToStringIfThenElse = new ConcurrentBag<Func<LabelTarget, Expression, Expression, Type, Expression>>();
|
||||||
public static Expression GetDataReaderValueBlockExpression(Type type, Expression value)
|
public static Expression GetDataReaderValueBlockExpression(Type type, Expression value)
|
||||||
{
|
{
|
||||||
var returnTarget = Expression.Label(typeof(object));
|
var returnTarget = Expression.Label(typeof(object));
|
||||||
@ -1728,11 +1729,14 @@ namespace FreeSql.Internal
|
|||||||
default:
|
default:
|
||||||
foreach (var switchFunc in GetDataReaderValueBlockExpressionSwitchTypeFullName)
|
foreach (var switchFunc in GetDataReaderValueBlockExpressionSwitchTypeFullName)
|
||||||
{
|
{
|
||||||
var switchFuncRet = switchFunc(returnTarget, valueExp, type.FullName);
|
var switchFuncRet = switchFunc(returnTarget, valueExp, type);
|
||||||
if (switchFuncRet != null) return switchFuncRet;
|
if (switchFuncRet != null) return switchFuncRet;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Expression callToStringExp = Expression.Return(returnTarget, Expression.Convert(Expression.Call(MethodToString, valueExp), typeof(object)));
|
||||||
|
foreach (var toStringFunc in GetDataReaderValueBlockExpressionObjectToStringIfThenElse)
|
||||||
|
callToStringExp = toStringFunc(returnTarget, valueExp, callToStringExp, type);
|
||||||
Expression switchExp = null;
|
Expression switchExp = null;
|
||||||
if (tryparseExp != null)
|
if (tryparseExp != null)
|
||||||
switchExp = Expression.Switch(
|
switchExp = Expression.Switch(
|
||||||
@ -1753,12 +1757,12 @@ namespace FreeSql.Internal
|
|||||||
Expression.SwitchCase(Expression.Return(returnTarget, Expression.Call(MethodConvertChangeType, valueExp, Expression.Constant(type, typeof(Type)))), Expression.Constant(type))
|
Expression.SwitchCase(Expression.Return(returnTarget, Expression.Call(MethodConvertChangeType, valueExp, Expression.Constant(type, typeof(Type)))), Expression.Constant(type))
|
||||||
);
|
);
|
||||||
else if (type == typeof(string))
|
else if (type == typeof(string))
|
||||||
switchExp = Expression.Return(returnTarget, Expression.Convert(Expression.Call(MethodToString, valueExp), typeof(object)));
|
switchExp = callToStringExp;
|
||||||
else
|
else
|
||||||
switchExp = Expression.Return(returnTarget, Expression.Call(MethodConvertChangeType, valueExp, Expression.Constant(type, typeof(Type))));
|
switchExp = Expression.Return(returnTarget, Expression.Call(MethodConvertChangeType, valueExp, Expression.Constant(type, typeof(Type))));
|
||||||
|
|
||||||
var defaultRetExp = type == typeof(string) ?
|
var defaultRetExp = type == typeof(string) ?
|
||||||
Expression.Return(returnTarget, Expression.Convert(Expression.Call(MethodToString, valueExp), typeof(object))) :
|
callToStringExp :
|
||||||
Expression.Return(returnTarget, Expression.Call(MethodConvertChangeType, valueExp, Expression.Constant(type, typeof(Type))));
|
Expression.Return(returnTarget, Expression.Call(MethodConvertChangeType, valueExp, Expression.Constant(type, typeof(Type))));
|
||||||
|
|
||||||
return Expression.IfThenElse(
|
return Expression.IfThenElse(
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net452</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net452</TargetFrameworks>
|
||||||
<Version>0.9.12</Version>
|
<Version>0.9.15</Version>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<Authors>YeXiangQin</Authors>
|
<Authors>YeXiangQin</Authors>
|
||||||
<Description>FreeSql 数据库实现,基于 MySql 5.6</Description>
|
<Description>FreeSql 数据库实现,基于 MySql 5.6</Description>
|
||||||
@ -12,6 +12,7 @@
|
|||||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||||
<PackageTags>FreeSql;ORM</PackageTags>
|
<PackageTags>FreeSql;ORM</PackageTags>
|
||||||
<PackageId>$(AssemblyName)</PackageId>
|
<PackageId>$(AssemblyName)</PackageId>
|
||||||
|
<PackageIconUrl>https://github.com/2881099/FreeSql/blob/master/logo.png</PackageIconUrl>
|
||||||
<Title>$(AssemblyName)</Title>
|
<Title>$(AssemblyName)</Title>
|
||||||
<IsPackable>true</IsPackable>
|
<IsPackable>true</IsPackable>
|
||||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||||
|
@ -310,7 +310,7 @@ namespace FreeSql.MySql
|
|||||||
case "Equals": return $"({left} = {getExp(exp.Arguments[0])})";
|
case "Equals": return $"({left} = {getExp(exp.Arguments[0])})";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new Exception($"MySqlExpression 未实现函数表达式 {exp} 解析");
|
return null;
|
||||||
}
|
}
|
||||||
public override string ExpressionLambdaToSqlCallMath(MethodCallExpression exp, ExpTSC tsc)
|
public override string ExpressionLambdaToSqlCallMath(MethodCallExpression exp, ExpTSC tsc)
|
||||||
{
|
{
|
||||||
@ -338,7 +338,7 @@ namespace FreeSql.MySql
|
|||||||
case "Atan2": return $"atan2({getExp(exp.Arguments[0])}, {getExp(exp.Arguments[1])})";
|
case "Atan2": return $"atan2({getExp(exp.Arguments[0])}, {getExp(exp.Arguments[1])})";
|
||||||
case "Truncate": return $"truncate({getExp(exp.Arguments[0])}, 0)";
|
case "Truncate": return $"truncate({getExp(exp.Arguments[0])}, 0)";
|
||||||
}
|
}
|
||||||
throw new Exception($"MySqlExpression 未实现函数表达式 {exp} 解析");
|
return null;
|
||||||
}
|
}
|
||||||
public override string ExpressionLambdaToSqlCallDateTime(MethodCallExpression exp, ExpTSC tsc)
|
public override string ExpressionLambdaToSqlCallDateTime(MethodCallExpression exp, ExpTSC tsc)
|
||||||
{
|
{
|
||||||
@ -388,7 +388,7 @@ namespace FreeSql.MySql
|
|||||||
case "ToString": return $"date_format({left}, '%Y-%m-%d %H:%i:%s.%f')";
|
case "ToString": return $"date_format({left}, '%Y-%m-%d %H:%i:%s.%f')";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new Exception($"MySqlExpression 未实现函数表达式 {exp} 解析");
|
return null;
|
||||||
}
|
}
|
||||||
public override string ExpressionLambdaToSqlCallTimeSpan(MethodCallExpression exp, ExpTSC tsc)
|
public override string ExpressionLambdaToSqlCallTimeSpan(MethodCallExpression exp, ExpTSC tsc)
|
||||||
{
|
{
|
||||||
@ -424,7 +424,7 @@ namespace FreeSql.MySql
|
|||||||
case "ToString": return $"cast({left} as char)";
|
case "ToString": return $"cast({left} as char)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new Exception($"MySqlExpression 未实现函数表达式 {exp} 解析");
|
return null;
|
||||||
}
|
}
|
||||||
public override string ExpressionLambdaToSqlCallConvert(MethodCallExpression exp, ExpTSC tsc)
|
public override string ExpressionLambdaToSqlCallConvert(MethodCallExpression exp, ExpTSC tsc)
|
||||||
{
|
{
|
||||||
@ -450,7 +450,7 @@ namespace FreeSql.MySql
|
|||||||
case "ToUInt64": return $"cast({getExp(exp.Arguments[0])} as unsigned)";
|
case "ToUInt64": return $"cast({getExp(exp.Arguments[0])} as unsigned)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new Exception($"MySqlExpression 未实现函数表达式 {exp} 解析");
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,9 +22,9 @@ namespace FreeSql.MySql
|
|||||||
Utils.dicExecuteArrayRowReadClassOrTuple[typeof(MygisMultiPolygon)] = true;
|
Utils.dicExecuteArrayRowReadClassOrTuple[typeof(MygisMultiPolygon)] = true;
|
||||||
|
|
||||||
var MethodMygisGeometryParse = typeof(MygisGeometry).GetMethod("Parse", new[] { typeof(string) });
|
var MethodMygisGeometryParse = typeof(MygisGeometry).GetMethod("Parse", new[] { typeof(string) });
|
||||||
Utils.GetDataReaderValueBlockExpressionSwitchTypeFullName.Add((LabelTarget returnTarget, Expression valueExp, string typeFullName) =>
|
Utils.GetDataReaderValueBlockExpressionSwitchTypeFullName.Add((LabelTarget returnTarget, Expression valueExp, Type type) =>
|
||||||
{
|
{
|
||||||
switch (typeFullName)
|
switch (type.FullName)
|
||||||
{
|
{
|
||||||
case "MygisPoint": return Expression.Return(returnTarget, Expression.TypeAs(Expression.Call(MethodMygisGeometryParse, Expression.Convert(valueExp, typeof(string))), typeof(MygisPoint)));
|
case "MygisPoint": return Expression.Return(returnTarget, Expression.TypeAs(Expression.Call(MethodMygisGeometryParse, Expression.Convert(valueExp, typeof(string))), typeof(MygisPoint)));
|
||||||
case "MygisLineString": return Expression.Return(returnTarget, Expression.TypeAs(Expression.Call(MethodMygisGeometryParse, Expression.Convert(valueExp, typeof(string))), typeof(MygisLineString)));
|
case "MygisLineString": return Expression.Return(returnTarget, Expression.TypeAs(Expression.Call(MethodMygisGeometryParse, Expression.Convert(valueExp, typeof(string))), typeof(MygisLineString)));
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
|
||||||
<Version>0.9.12</Version>
|
<Version>0.9.15</Version>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<Authors>YeXiangQin</Authors>
|
<Authors>YeXiangQin</Authors>
|
||||||
<Description>FreeSql 数据库实现,基于 MySql 5.6</Description>
|
<Description>FreeSql 数据库实现,基于 MySql 5.6</Description>
|
||||||
@ -12,6 +12,7 @@
|
|||||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||||
<PackageTags>FreeSql;ORM</PackageTags>
|
<PackageTags>FreeSql;ORM</PackageTags>
|
||||||
<PackageId>$(AssemblyName)</PackageId>
|
<PackageId>$(AssemblyName)</PackageId>
|
||||||
|
<PackageIconUrl>https://github.com/2881099/FreeSql/blob/master/logo.png</PackageIconUrl>
|
||||||
<Title>$(AssemblyName)</Title>
|
<Title>$(AssemblyName)</Title>
|
||||||
<IsPackable>true</IsPackable>
|
<IsPackable>true</IsPackable>
|
||||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
|
||||||
<Version>0.9.12</Version>
|
<Version>0.9.15</Version>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<Authors>YeXiangQin</Authors>
|
<Authors>YeXiangQin</Authors>
|
||||||
<Description>FreeSql 数据库实现,基于 Oracle 11</Description>
|
<Description>FreeSql 数据库实现,基于 Oracle 11</Description>
|
||||||
@ -12,6 +12,7 @@
|
|||||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||||
<PackageTags>FreeSql;ORM</PackageTags>
|
<PackageTags>FreeSql;ORM</PackageTags>
|
||||||
<PackageId>$(AssemblyName)</PackageId>
|
<PackageId>$(AssemblyName)</PackageId>
|
||||||
|
<PackageIconUrl>https://github.com/2881099/FreeSql/blob/master/logo.png</PackageIconUrl>
|
||||||
<Title>$(AssemblyName)</Title>
|
<Title>$(AssemblyName)</Title>
|
||||||
<IsPackable>true</IsPackable>
|
<IsPackable>true</IsPackable>
|
||||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||||
|
@ -310,7 +310,7 @@ namespace FreeSql.Oracle
|
|||||||
case "Equals": return $"({left} = {getExp(exp.Arguments[0])})";
|
case "Equals": return $"({left} = {getExp(exp.Arguments[0])})";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new Exception($"OracleExpression 未实现函数表达式 {exp} 解析");
|
return null;
|
||||||
}
|
}
|
||||||
public override string ExpressionLambdaToSqlCallMath(MethodCallExpression exp, ExpTSC tsc)
|
public override string ExpressionLambdaToSqlCallMath(MethodCallExpression exp, ExpTSC tsc)
|
||||||
{
|
{
|
||||||
@ -340,7 +340,7 @@ namespace FreeSql.Oracle
|
|||||||
//case "Atan2": return $"atan2({getExp(exp.Arguments[0])}, {getExp(exp.Arguments[1])})";
|
//case "Atan2": return $"atan2({getExp(exp.Arguments[0])}, {getExp(exp.Arguments[1])})";
|
||||||
case "Truncate": return $"trunc({getExp(exp.Arguments[0])}, 0)";
|
case "Truncate": return $"trunc({getExp(exp.Arguments[0])}, 0)";
|
||||||
}
|
}
|
||||||
throw new Exception($"OracleExpression 未实现函数表达式 {exp} 解析");
|
return null;
|
||||||
}
|
}
|
||||||
public override string ExpressionLambdaToSqlCallDateTime(MethodCallExpression exp, ExpTSC tsc)
|
public override string ExpressionLambdaToSqlCallDateTime(MethodCallExpression exp, ExpTSC tsc)
|
||||||
{
|
{
|
||||||
@ -390,7 +390,7 @@ namespace FreeSql.Oracle
|
|||||||
case "ToString": return $"to_char({left},'YYYY-MM-DD HH24:MI:SS.FF6')";
|
case "ToString": return $"to_char({left},'YYYY-MM-DD HH24:MI:SS.FF6')";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new Exception($"OracleExpression 未实现函数表达式 {exp} 解析");
|
return null;
|
||||||
}
|
}
|
||||||
public override string ExpressionLambdaToSqlCallTimeSpan(MethodCallExpression exp, ExpTSC tsc)
|
public override string ExpressionLambdaToSqlCallTimeSpan(MethodCallExpression exp, ExpTSC tsc)
|
||||||
{
|
{
|
||||||
@ -426,7 +426,7 @@ namespace FreeSql.Oracle
|
|||||||
case "ToString": return $"to_char({left})";
|
case "ToString": return $"to_char({left})";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new Exception($"OracleExpression 未实现函数表达式 {exp} 解析");
|
return null;
|
||||||
}
|
}
|
||||||
public override string ExpressionLambdaToSqlCallConvert(MethodCallExpression exp, ExpTSC tsc)
|
public override string ExpressionLambdaToSqlCallConvert(MethodCallExpression exp, ExpTSC tsc)
|
||||||
{
|
{
|
||||||
@ -452,7 +452,7 @@ namespace FreeSql.Oracle
|
|||||||
case "ToUInt64": return $"cast({getExp(exp.Arguments[0])} as number)";
|
case "ToUInt64": return $"cast({getExp(exp.Arguments[0])} as number)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new Exception($"OracleExpression 未实现函数表达式 {exp} 解析");
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
|
||||||
<Version>0.9.12</Version>
|
<Version>0.9.15</Version>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<Authors>YeXiangQin</Authors>
|
<Authors>YeXiangQin</Authors>
|
||||||
<Description>FreeSql 数据库实现,基于 PostgreSQL 9.5</Description>
|
<Description>FreeSql 数据库实现,基于 PostgreSQL 9.5</Description>
|
||||||
@ -12,6 +12,7 @@
|
|||||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||||
<PackageTags>FreeSql;ORM</PackageTags>
|
<PackageTags>FreeSql;ORM</PackageTags>
|
||||||
<PackageId>$(AssemblyName)</PackageId>
|
<PackageId>$(AssemblyName)</PackageId>
|
||||||
|
<PackageIconUrl>https://github.com/2881099/FreeSql/blob/master/logo.png</PackageIconUrl>
|
||||||
<Title>$(AssemblyName)</Title>
|
<Title>$(AssemblyName)</Title>
|
||||||
<IsPackable>true</IsPackable>
|
<IsPackable>true</IsPackable>
|
||||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||||
|
@ -421,7 +421,7 @@ namespace FreeSql.PostgreSQL
|
|||||||
case "Equals": return $"({left} = ({getExp(exp.Arguments[0])})::varchar)";
|
case "Equals": return $"({left} = ({getExp(exp.Arguments[0])})::varchar)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new Exception($"PostgreSQLExpression 未实现函数表达式 {exp} 解析");
|
return null;
|
||||||
}
|
}
|
||||||
public override string ExpressionLambdaToSqlCallMath(MethodCallExpression exp, ExpTSC tsc)
|
public override string ExpressionLambdaToSqlCallMath(MethodCallExpression exp, ExpTSC tsc)
|
||||||
{
|
{
|
||||||
@ -449,7 +449,7 @@ namespace FreeSql.PostgreSQL
|
|||||||
case "Atan2": return $"atan2({getExp(exp.Arguments[0])}, {getExp(exp.Arguments[1])})";
|
case "Atan2": return $"atan2({getExp(exp.Arguments[0])}, {getExp(exp.Arguments[1])})";
|
||||||
case "Truncate": return $"trunc({getExp(exp.Arguments[0])}, 0)";
|
case "Truncate": return $"trunc({getExp(exp.Arguments[0])}, 0)";
|
||||||
}
|
}
|
||||||
throw new Exception($"PostgreSQLExpression 未实现函数表达式 {exp} 解析");
|
return null;
|
||||||
}
|
}
|
||||||
public override string ExpressionLambdaToSqlCallDateTime(MethodCallExpression exp, ExpTSC tsc)
|
public override string ExpressionLambdaToSqlCallDateTime(MethodCallExpression exp, ExpTSC tsc)
|
||||||
{
|
{
|
||||||
@ -499,7 +499,7 @@ namespace FreeSql.PostgreSQL
|
|||||||
case "ToString": return $"to_char({left}, 'YYYY-MM-DD HH24:MI:SS.US')";
|
case "ToString": return $"to_char({left}, 'YYYY-MM-DD HH24:MI:SS.US')";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new Exception($"PostgreSQLExpression 未实现函数表达式 {exp} 解析");
|
return null;
|
||||||
}
|
}
|
||||||
public override string ExpressionLambdaToSqlCallTimeSpan(MethodCallExpression exp, ExpTSC tsc)
|
public override string ExpressionLambdaToSqlCallTimeSpan(MethodCallExpression exp, ExpTSC tsc)
|
||||||
{
|
{
|
||||||
@ -535,7 +535,7 @@ namespace FreeSql.PostgreSQL
|
|||||||
case "ToString": return $"({left})::varchar";
|
case "ToString": return $"({left})::varchar";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new Exception($"PostgreSQLExpression 未实现函数表达式 {exp} 解析");
|
return null;
|
||||||
}
|
}
|
||||||
public override string ExpressionLambdaToSqlCallConvert(MethodCallExpression exp, ExpTSC tsc)
|
public override string ExpressionLambdaToSqlCallConvert(MethodCallExpression exp, ExpTSC tsc)
|
||||||
{
|
{
|
||||||
@ -561,7 +561,7 @@ namespace FreeSql.PostgreSQL
|
|||||||
case "ToUInt64": return $"({getExp(exp.Arguments[0])})::int8";
|
case "ToUInt64": return $"({getExp(exp.Arguments[0])})::int8";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new Exception($"PostgreSQLExpression 未实现函数表达式 {exp} 解析");
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,9 +51,9 @@ namespace FreeSql.PostgreSQL
|
|||||||
var MethodJTokenParse = typeof(JToken).GetMethod("Parse", new[] { typeof(string) });
|
var MethodJTokenParse = typeof(JToken).GetMethod("Parse", new[] { typeof(string) });
|
||||||
var MethodJObjectParse = typeof(JObject).GetMethod("Parse", new[] { typeof(string) });
|
var MethodJObjectParse = typeof(JObject).GetMethod("Parse", new[] { typeof(string) });
|
||||||
var MethodJArrayParse = typeof(JArray).GetMethod("Parse", new[] { typeof(string) });
|
var MethodJArrayParse = typeof(JArray).GetMethod("Parse", new[] { typeof(string) });
|
||||||
Utils.GetDataReaderValueBlockExpressionSwitchTypeFullName.Add((LabelTarget returnTarget, Expression valueExp, string typeFullName) =>
|
Utils.GetDataReaderValueBlockExpressionSwitchTypeFullName.Add((LabelTarget returnTarget, Expression valueExp, Type type) =>
|
||||||
{
|
{
|
||||||
switch (typeFullName)
|
switch (type.FullName)
|
||||||
{
|
{
|
||||||
case "Newtonsoft.Json.Linq.JToken": return Expression.Return(returnTarget, Expression.TypeAs(Expression.Call(MethodJTokenParse, Expression.Convert(valueExp, typeof(string))), typeof(JToken)));
|
case "Newtonsoft.Json.Linq.JToken": return Expression.Return(returnTarget, Expression.TypeAs(Expression.Call(MethodJTokenParse, Expression.Convert(valueExp, typeof(string))), typeof(JToken)));
|
||||||
case "Newtonsoft.Json.Linq.JObject": return Expression.Return(returnTarget, Expression.TypeAs(Expression.Call(MethodJObjectParse, Expression.Convert(valueExp, typeof(string))), typeof(JObject)));
|
case "Newtonsoft.Json.Linq.JObject": return Expression.Return(returnTarget, Expression.TypeAs(Expression.Call(MethodJObjectParse, Expression.Convert(valueExp, typeof(string))), typeof(JObject)));
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net451</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net451</TargetFrameworks>
|
||||||
<Version>0.9.12</Version>
|
<Version>0.9.15</Version>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<Authors>YeXiangQin</Authors>
|
<Authors>YeXiangQin</Authors>
|
||||||
<Description>FreeSql 数据库实现,基于 SqlServer 2005+,并根据版本适配分页方法:row_number 或 offset fetch next</Description>
|
<Description>FreeSql 数据库实现,基于 SqlServer 2005+,并根据版本适配分页方法:row_number 或 offset fetch next</Description>
|
||||||
@ -12,6 +12,7 @@
|
|||||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||||
<PackageTags>FreeSql;ORM</PackageTags>
|
<PackageTags>FreeSql;ORM</PackageTags>
|
||||||
<PackageId>$(AssemblyName)</PackageId>
|
<PackageId>$(AssemblyName)</PackageId>
|
||||||
|
<PackageIconUrl>https://github.com/2881099/FreeSql/blob/master/logo.png</PackageIconUrl>
|
||||||
<Title>$(AssemblyName)</Title>
|
<Title>$(AssemblyName)</Title>
|
||||||
<IsPackable>true</IsPackable>
|
<IsPackable>true</IsPackable>
|
||||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||||
|
@ -292,7 +292,7 @@ namespace FreeSql.SqlServer
|
|||||||
case "Equals": return $"({left} = {getExp(exp.Arguments[0])})";
|
case "Equals": return $"({left} = {getExp(exp.Arguments[0])})";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new Exception($"SqlServerExpression 未实现函数表达式 {exp} 解析");
|
return null;
|
||||||
}
|
}
|
||||||
public override string ExpressionLambdaToSqlCallMath(MethodCallExpression exp, ExpTSC tsc)
|
public override string ExpressionLambdaToSqlCallMath(MethodCallExpression exp, ExpTSC tsc)
|
||||||
{
|
{
|
||||||
@ -320,7 +320,7 @@ namespace FreeSql.SqlServer
|
|||||||
case "Atan2": return $"atan2({getExp(exp.Arguments[0])}, {getExp(exp.Arguments[1])})";
|
case "Atan2": return $"atan2({getExp(exp.Arguments[0])}, {getExp(exp.Arguments[1])})";
|
||||||
case "Truncate": return $"floor({getExp(exp.Arguments[0])})";
|
case "Truncate": return $"floor({getExp(exp.Arguments[0])})";
|
||||||
}
|
}
|
||||||
throw new Exception($"SqlServerExpression 未实现函数表达式 {exp} 解析");
|
return null;
|
||||||
}
|
}
|
||||||
public override string ExpressionLambdaToSqlCallDateTime(MethodCallExpression exp, ExpTSC tsc)
|
public override string ExpressionLambdaToSqlCallDateTime(MethodCallExpression exp, ExpTSC tsc)
|
||||||
{
|
{
|
||||||
@ -370,7 +370,7 @@ namespace FreeSql.SqlServer
|
|||||||
case "ToString": return $"convert(varchar, {left}, 121)";
|
case "ToString": return $"convert(varchar, {left}, 121)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new Exception($"SqlServerExpression 未实现函数表达式 {exp} 解析");
|
return null;
|
||||||
}
|
}
|
||||||
public override string ExpressionLambdaToSqlCallTimeSpan(MethodCallExpression exp, ExpTSC tsc)
|
public override string ExpressionLambdaToSqlCallTimeSpan(MethodCallExpression exp, ExpTSC tsc)
|
||||||
{
|
{
|
||||||
@ -406,7 +406,7 @@ namespace FreeSql.SqlServer
|
|||||||
case "ToString": return $"cast({left} as varchar)";
|
case "ToString": return $"cast({left} as varchar)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new Exception($"SqlServerExpression 未实现函数表达式 {exp} 解析");
|
return null;
|
||||||
}
|
}
|
||||||
public override string ExpressionLambdaToSqlCallConvert(MethodCallExpression exp, ExpTSC tsc)
|
public override string ExpressionLambdaToSqlCallConvert(MethodCallExpression exp, ExpTSC tsc)
|
||||||
{
|
{
|
||||||
@ -432,7 +432,7 @@ namespace FreeSql.SqlServer
|
|||||||
case "ToUInt64": return $"cast({getExp(exp.Arguments[0])} as bigint)";
|
case "ToUInt64": return $"cast({getExp(exp.Arguments[0])} as bigint)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new Exception($"SqlServerExpression 未实现函数表达式 {exp} 解析");
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
|
||||||
<Version>0.9.12</Version>
|
<Version>0.9.15</Version>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<Authors>YeXiangQin</Authors>
|
<Authors>YeXiangQin</Authors>
|
||||||
<Description>FreeSql 数据库实现,基于 Sqlite 3.0</Description>
|
<Description>FreeSql 数据库实现,基于 Sqlite 3.0</Description>
|
||||||
@ -12,6 +12,7 @@
|
|||||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||||
<PackageTags>FreeSql;ORM</PackageTags>
|
<PackageTags>FreeSql;ORM</PackageTags>
|
||||||
<PackageId>$(AssemblyName)</PackageId>
|
<PackageId>$(AssemblyName)</PackageId>
|
||||||
|
<PackageIconUrl>https://github.com/2881099/FreeSql/blob/master/logo.png</PackageIconUrl>
|
||||||
<Title>$(AssemblyName)</Title>
|
<Title>$(AssemblyName)</Title>
|
||||||
<IsPackable>true</IsPackable>
|
<IsPackable>true</IsPackable>
|
||||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||||
|
@ -314,7 +314,7 @@ namespace FreeSql.Sqlite
|
|||||||
case "Equals": return $"({left} = {getExp(exp.Arguments[0])})";
|
case "Equals": return $"({left} = {getExp(exp.Arguments[0])})";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new Exception($"SqliteExpression 未实现函数表达式 {exp} 解析");
|
return null;
|
||||||
}
|
}
|
||||||
public override string ExpressionLambdaToSqlCallMath(MethodCallExpression exp, ExpTSC tsc)
|
public override string ExpressionLambdaToSqlCallMath(MethodCallExpression exp, ExpTSC tsc)
|
||||||
{
|
{
|
||||||
@ -342,7 +342,7 @@ namespace FreeSql.Sqlite
|
|||||||
case "Atan2": return $"atan2({getExp(exp.Arguments[0])}, {getExp(exp.Arguments[1])})";
|
case "Atan2": return $"atan2({getExp(exp.Arguments[0])}, {getExp(exp.Arguments[1])})";
|
||||||
//case "Truncate": return $"truncate({getExp(exp.Arguments[0])}, 0)";
|
//case "Truncate": return $"truncate({getExp(exp.Arguments[0])}, 0)";
|
||||||
}
|
}
|
||||||
throw new Exception($"SqliteExpression 未实现函数表达式 {exp} 解析");
|
return null;
|
||||||
}
|
}
|
||||||
public override string ExpressionLambdaToSqlCallDateTime(MethodCallExpression exp, ExpTSC tsc)
|
public override string ExpressionLambdaToSqlCallDateTime(MethodCallExpression exp, ExpTSC tsc)
|
||||||
{
|
{
|
||||||
@ -392,7 +392,7 @@ namespace FreeSql.Sqlite
|
|||||||
case "ToString": return $"strftime('%Y-%m-%d %H:%M.%f',{left})";
|
case "ToString": return $"strftime('%Y-%m-%d %H:%M.%f',{left})";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new Exception($"SqliteExpression 未实现函数表达式 {exp} 解析");
|
return null;
|
||||||
}
|
}
|
||||||
public override string ExpressionLambdaToSqlCallTimeSpan(MethodCallExpression exp, ExpTSC tsc)
|
public override string ExpressionLambdaToSqlCallTimeSpan(MethodCallExpression exp, ExpTSC tsc)
|
||||||
{
|
{
|
||||||
@ -428,7 +428,7 @@ namespace FreeSql.Sqlite
|
|||||||
case "ToString": return $"cast({left} as character)";
|
case "ToString": return $"cast({left} as character)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new Exception($"SqliteExpression 未实现函数表达式 {exp} 解析");
|
return null;
|
||||||
}
|
}
|
||||||
public override string ExpressionLambdaToSqlCallConvert(MethodCallExpression exp, ExpTSC tsc)
|
public override string ExpressionLambdaToSqlCallConvert(MethodCallExpression exp, ExpTSC tsc)
|
||||||
{
|
{
|
||||||
@ -454,7 +454,7 @@ namespace FreeSql.Sqlite
|
|||||||
case "ToUInt64": return $"cast({getExp(exp.Arguments[0])} as decimal(21,0))";
|
case "ToUInt64": return $"cast({getExp(exp.Arguments[0])} as decimal(21,0))";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new Exception($"SqliteExpression 未实现函数表达式 {exp} 解析");
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,8 @@ FreeSql 是一个功能强大的对象关系映射程序(O/RM),支持 .NETCore
|
|||||||
| FreeSql.Provider.Sqlite | NETStandard2.0、net45 |
|
| FreeSql.Provider.Sqlite | NETStandard2.0、net45 |
|
||||||
| FreeSql.Provider.Oracle | NETStandard2.0、net45 |
|
| FreeSql.Provider.Oracle | NETStandard2.0、net45 |
|
||||||
| FreeSql.Extensions.LazyLoading | NETStandard2.0、net45 |
|
| FreeSql.Extensions.LazyLoading | NETStandard2.0、net45 |
|
||||||
|
| FreeSql.Extensions.JsonMap | NETStandard2.0、net45 |
|
||||||
|
| FreeSql.Extensions.BaseEntity | NETStandard2.0 |
|
||||||
|
|
||||||
# Quick start
|
# Quick start
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user