mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 02:32:50 +08:00
v3.2.666-preview20220824
This commit is contained in:
parent
25b98f2fe9
commit
3193aa79d5
@ -11,7 +11,7 @@
|
|||||||
<!--
|
<!--
|
||||||
经常出于版本交叉问题,暂时关闭,在每个项目上设置版本号
|
经常出于版本交叉问题,暂时关闭,在每个项目上设置版本号
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Version>3.2.666-preview20220823</Version>
|
<Version>3.2.666-preview20220824</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
<Version>3.2.666-preview20220823</Version>
|
<Version>3.2.666-preview20220824</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.666-preview20220823</Version>
|
<Version>3.2.666-preview20220824</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
<Title>$(AssemblyName)</Title>
|
<Title>$(AssemblyName)</Title>
|
||||||
<IsPackable>true</IsPackable>
|
<IsPackable>true</IsPackable>
|
||||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||||
<Version>3.2.666-preview20220823</Version>
|
<Version>3.2.666-preview20220824</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.666-preview20220823</Version>
|
<Version>3.2.666-preview20220824</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
<PackageProjectUrl>https://github.com/2881099/FreeSql</PackageProjectUrl>
|
<PackageProjectUrl>https://github.com/2881099/FreeSql</PackageProjectUrl>
|
||||||
<RepositoryUrl>https://github.com/2881099/FreeSql</RepositoryUrl>
|
<RepositoryUrl>https://github.com/2881099/FreeSql</RepositoryUrl>
|
||||||
<PackageTags>FreeSql DbFirst 实体生成器</PackageTags>
|
<PackageTags>FreeSql DbFirst 实体生成器</PackageTags>
|
||||||
<Version>3.2.666-preview20220823</Version>
|
<Version>3.2.666-preview20220824</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.666-preview20220823</Version>
|
<Version>3.2.666-preview20220824</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.666-preview20220823</Version>
|
<Version>3.2.666-preview20220824</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -800,14 +800,5 @@
|
|||||||
<param name="that"></param>
|
<param name="that"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:Microsoft.Extensions.DependencyInjection.FreeSqlRepositoryDependencyInjection.AddFreeRepository(Microsoft.Extensions.DependencyInjection.IServiceCollection,System.Action{FreeSql.FluentDataFilter},System.Reflection.Assembly[])">
|
|
||||||
<summary>
|
|
||||||
批量注入 Repository,可以参考代码自行调整
|
|
||||||
</summary>
|
|
||||||
<param name="services"></param>
|
|
||||||
<param name="globalDataFilter"></param>
|
|
||||||
<param name="assemblies"></param>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
</members>
|
</members>
|
||||||
</doc>
|
</doc>
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.666-preview20220823</Version>
|
<Version>3.2.666-preview20220824</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -1292,7 +1292,7 @@ FROM ( SELECT max(a.`Id`) `TaskId`, max(a.`Type`) `TaskType`, a.`ProcessId`, a.`
|
|||||||
WHERE (a.`IsFinished` = 1 AND (a.`AuditorId` = '1' OR a.`AuditorId` = '1cb71584-a6dd-4b26-8c88-ed9fb8cf87a3'))
|
WHERE (a.`IsFinished` = 1 AND (a.`AuditorId` = '1' OR a.`AuditorId` = '1cb71584-a6dd-4b26-8c88-ed9fb8cf87a3'))
|
||||||
GROUP BY a.`ProcessId`, a.`NodeId`, a.`NodeName` ) a
|
GROUP BY a.`ProcessId`, a.`NodeId`, a.`NodeName` ) a
|
||||||
LEFT JOIN `WF_ProcessInstance` b ON b.`Id` = a.`ProcessId`
|
LEFT JOIN `WF_ProcessInstance` b ON b.`Id` = a.`ProcessId`
|
||||||
WHERE ((b.`IsFinished` OR a.`TaskType` = 3) AND b.`EnabledMark` = 1)", groupsql12);
|
WHERE ((b.`IsFinished` = 1 OR a.`TaskType` = 3) AND b.`EnabledMark` = 1)", groupsql12);
|
||||||
|
|
||||||
var grouplist12 = g.mysql.Select<WF_TaskGroupBy, WF_ProcessInstance>()
|
var grouplist12 = g.mysql.Select<WF_TaskGroupBy, WF_ProcessInstance>()
|
||||||
.AsTable((type, old) => type == typeof(WF_TaskGroupBy) ? $"( {sqltmp12} )" : null)
|
.AsTable((type, old) => type == typeof(WF_TaskGroupBy) ? $"( {sqltmp12} )" : null)
|
||||||
|
@ -1172,7 +1172,7 @@ FROM ( SELECT max(a.`Id`) `TaskId`, max(a.`Type`) `TaskType`, a.`ProcessId`, a.`
|
|||||||
WHERE (a.`IsFinished` = 1 AND (a.`AuditorId` = '1' OR a.`AuditorId` = '1cb71584-a6dd-4b26-8c88-ed9fb8cf87a3'))
|
WHERE (a.`IsFinished` = 1 AND (a.`AuditorId` = '1' OR a.`AuditorId` = '1cb71584-a6dd-4b26-8c88-ed9fb8cf87a3'))
|
||||||
GROUP BY a.`ProcessId`, a.`NodeId`, a.`NodeName` ) a
|
GROUP BY a.`ProcessId`, a.`NodeId`, a.`NodeName` ) a
|
||||||
LEFT JOIN `WF_ProcessInstance` b ON b.`Id` = a.`ProcessId`
|
LEFT JOIN `WF_ProcessInstance` b ON b.`Id` = a.`ProcessId`
|
||||||
WHERE ((b.`IsFinished` OR a.`TaskType` = 3) AND b.`EnabledMark` = 1)", groupsql12);
|
WHERE ((b.`IsFinished` = 1 OR a.`TaskType` = 3) AND b.`EnabledMark` = 1)", groupsql12);
|
||||||
|
|
||||||
var grouplist12 = g.mysql.Select<WF_TaskGroupBy, WF_ProcessInstance>()
|
var grouplist12 = g.mysql.Select<WF_TaskGroupBy, WF_ProcessInstance>()
|
||||||
.AsTable((type, old) => type == typeof(WF_TaskGroupBy) ? $"( {sqltmp12} )" : null)
|
.AsTable((type, old) => type == typeof(WF_TaskGroupBy) ? $"( {sqltmp12} )" : null)
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFrameworks>net6.0;netcoreapp3.1;</TargetFrameworks>
|
||||||
|
<IsPackable>false</IsPackable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
|
<WarningLevel>3</WarningLevel>
|
||||||
|
<NoWarn>1701;1702;1591</NoWarn>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" />
|
||||||
|
<PackageReference Include="xunit" Version="2.4.1" />
|
||||||
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\Extensions\FreeSql.Extensions.LazyLoading\FreeSql.Extensions.LazyLoading.csproj" />
|
||||||
|
<ProjectReference Include="..\..\FreeSql.DbContext\FreeSql.DbContext.csproj" />
|
||||||
|
<ProjectReference Include="..\..\FreeSql\FreeSql.csproj" />
|
||||||
|
<ProjectReference Include="..\..\Providers\FreeSql.Provider.OracleOledb\FreeSql.Provider.OracleOledb.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
@ -0,0 +1,105 @@
|
|||||||
|
using FreeSql.DataAnnotations;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace FreeSql.Tests.OracleOledb
|
||||||
|
{
|
||||||
|
public class OracleOledbDeleteTest
|
||||||
|
{
|
||||||
|
|
||||||
|
IDelete<Topic> delete => g.oracle.Delete<Topic>(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
[Table(Name = "tb_topic22211")]
|
||||||
|
class Topic
|
||||||
|
{
|
||||||
|
[Column(IsIdentity = true, IsPrimary = true)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int? Clicks { get; set; }
|
||||||
|
public string Title { get; set; }
|
||||||
|
public DateTime CreateTime { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Dywhere()
|
||||||
|
{
|
||||||
|
Assert.Null(g.oracle.Delete<Topic>().ToSql());
|
||||||
|
var sql = g.oracle.Delete<Topic>(new[] { 1, 2 }).ToSql();
|
||||||
|
Assert.Equal("DELETE FROM \"TB_TOPIC22211\" WHERE (\"ID\" IN (1,2))", sql);
|
||||||
|
|
||||||
|
sql = g.oracle.Delete<Topic>(new Topic { Id = 1, Title = "test" }).ToSql();
|
||||||
|
Assert.Equal("DELETE FROM \"TB_TOPIC22211\" WHERE (\"ID\" = 1)", sql);
|
||||||
|
|
||||||
|
sql = g.oracle.Delete<Topic>(new[] { new Topic { Id = 1, Title = "test" }, new Topic { Id = 2, Title = "test" } }).ToSql();
|
||||||
|
Assert.Equal("DELETE FROM \"TB_TOPIC22211\" WHERE (\"ID\" IN (1,2))", sql);
|
||||||
|
|
||||||
|
sql = g.oracle.Delete<Topic>(new { id = 1 }).ToSql();
|
||||||
|
Assert.Equal("DELETE FROM \"TB_TOPIC22211\" WHERE (\"ID\" = 1)", sql);
|
||||||
|
|
||||||
|
sql = g.oracle.Delete<MultiPkTopic>(new[] { new { Id1 = 1, Id2 = 10 }, new { Id1 = 2, Id2 = 20 } }).ToSql();
|
||||||
|
Assert.Equal("DELETE FROM \"MULTIPKTOPIC\" WHERE (\"ID1\" = 1 AND \"ID2\" = 10 OR \"ID1\" = 2 AND \"ID2\" = 20)", sql);
|
||||||
|
}
|
||||||
|
class MultiPkTopic
|
||||||
|
{
|
||||||
|
[Column(IsPrimary = true)]
|
||||||
|
public int Id1 { get; set; }
|
||||||
|
[Column(IsPrimary = true)]
|
||||||
|
public int Id2 { get; set; }
|
||||||
|
public int Clicks { get; set; }
|
||||||
|
public string Title { get; set; }
|
||||||
|
public DateTime CreateTime { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Where()
|
||||||
|
{
|
||||||
|
var sql = delete.Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||||
|
Assert.Equal("DELETE FROM \"TB_TOPIC22211\" WHERE (\"ID\" = 1)", sql);
|
||||||
|
|
||||||
|
sql = delete.Where("id = :id", new { id = 1 }).ToSql().Replace("\r\n", "");
|
||||||
|
Assert.Equal("DELETE FROM \"TB_TOPIC22211\" WHERE (id = :id)", sql);
|
||||||
|
|
||||||
|
var item = new Topic { Id = 1, Title = "newtitle" };
|
||||||
|
sql = delete.Where(item).ToSql().Replace("\r\n", "");
|
||||||
|
Assert.Equal("DELETE FROM \"TB_TOPIC22211\" WHERE (\"ID\" = 1)", sql);
|
||||||
|
|
||||||
|
var items = new List<Topic>();
|
||||||
|
for (var a = 0; a < 10; a++) items.Add(new Topic { Id = a + 1, Title = $"newtitle{a}", Clicks = a * 100 });
|
||||||
|
|
||||||
|
sql = delete.Where(items).ToSql().Replace("\r\n", "");
|
||||||
|
Assert.Equal("DELETE FROM \"TB_TOPIC22211\" WHERE (\"ID\" IN (1,2,3,4,5,6,7,8,9,10))", sql);
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void ExecuteAffrows()
|
||||||
|
{
|
||||||
|
|
||||||
|
var id = g.oracle.Insert<Topic>(new Topic { Title = "xxxx", CreateTime = DateTime.Now }).ExecuteIdentity();
|
||||||
|
Assert.Equal(1, delete.Where(a => a.Id == id).ExecuteAffrows());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void ExecuteDeleted()
|
||||||
|
{
|
||||||
|
|
||||||
|
//var item = g.oracle.Insert<Topic>(new Topic { Title = "xxxx", CreateTime = DateTime.Now }).ExecuteInserted();
|
||||||
|
//Assert.Equal(item[0].Id, delete.Where(a => a.Id == item[0].Id).ExecuteDeleted()[0].Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void AsTable()
|
||||||
|
{
|
||||||
|
Assert.Null(g.oracle.Delete<Topic>().ToSql());
|
||||||
|
var sql = g.oracle.Delete<Topic>(new[] { 1, 2 }).AsTable(a => "TopicAsTable").ToSql();
|
||||||
|
Assert.Equal("DELETE FROM \"TOPICASTABLE\" WHERE (\"ID\" IN (1,2))", sql);
|
||||||
|
|
||||||
|
sql = g.oracle.Delete<Topic>(new Topic { Id = 1, Title = "test" }).AsTable(a => "TopicAsTable").ToSql();
|
||||||
|
Assert.Equal("DELETE FROM \"TOPICASTABLE\" WHERE (\"ID\" = 1)", sql);
|
||||||
|
|
||||||
|
sql = g.oracle.Delete<Topic>(new[] { new Topic { Id = 1, Title = "test" }, new Topic { Id = 2, Title = "test" } }).AsTable(a => "TopicAsTable").ToSql();
|
||||||
|
Assert.Equal("DELETE FROM \"TOPICASTABLE\" WHERE (\"ID\" IN (1,2))", sql);
|
||||||
|
|
||||||
|
sql = g.oracle.Delete<Topic>(new { id = 1 }).AsTable(a => "TopicAsTable").ToSql();
|
||||||
|
Assert.Equal("DELETE FROM \"TOPICASTABLE\" WHERE (\"ID\" = 1)", sql);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,425 @@
|
|||||||
|
using FreeSql.DataAnnotations;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace FreeSql.Tests.OracleOledb
|
||||||
|
{
|
||||||
|
public class OracleOledbInsertOrUpdateIfExistsDoNothingTest
|
||||||
|
{
|
||||||
|
IFreeSql fsql => g.oracle;
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void InsertOrUpdate_OnlyPrimary()
|
||||||
|
{
|
||||||
|
fsql.Delete<tbioudb01>().Where("1=1").ExecuteAffrows();
|
||||||
|
var iou = fsql.InsertOrUpdate<tbioudb01>().IfExistsDoNothing().SetSource(new tbioudb01 { id = 1 });
|
||||||
|
var sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOUDB01"" t1
|
||||||
|
USING (SELECT 1 as ""ID"" FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"")
|
||||||
|
values (t2.""ID"")", sql);
|
||||||
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbioudb01>().IfExistsDoNothing().SetSource(new tbioudb01 { id = 1 });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOUDB01"" t1
|
||||||
|
USING (SELECT 1 as ""ID"" FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"")
|
||||||
|
values (t2.""ID"")", sql);
|
||||||
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbioudb01>().IfExistsDoNothing().SetSource(new tbioudb01 { id = 2 });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOUDB01"" t1
|
||||||
|
USING (SELECT 2 as ""ID"" FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"")
|
||||||
|
values (t2.""ID"")", sql);
|
||||||
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbioudb01>().IfExistsDoNothing().SetSource(new[] { new tbioudb01 { id = 1 }, new tbioudb01 { id = 2 }, new tbioudb01 { id = 3 }, new tbioudb01 { id = 4 } });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOUDB01"" t1
|
||||||
|
USING (SELECT 1 as ""ID"" FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 2 FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 3 FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 4 FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"")
|
||||||
|
values (t2.""ID"")", sql);
|
||||||
|
Assert.Equal(2, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbioudb01>().IfExistsDoNothing().SetSource(new[] { new tbioudb01 { id = 1 }, new tbioudb01 { id = 2 }, new tbioudb01 { id = 3 }, new tbioudb01 { id = 4 } });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOUDB01"" t1
|
||||||
|
USING (SELECT 1 as ""ID"" FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 2 FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 3 FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 4 FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"")
|
||||||
|
values (t2.""ID"")", sql);
|
||||||
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
|
}
|
||||||
|
class tbioudb01
|
||||||
|
{
|
||||||
|
public int id { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void InsertOrUpdate_OnePrimary()
|
||||||
|
{
|
||||||
|
fsql.Delete<tbioudb02>().Where("1=1").ExecuteAffrows();
|
||||||
|
var iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new tbioudb02 { id = 1, name = "01" });
|
||||||
|
var sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOUDB02"" t1
|
||||||
|
USING (SELECT 1 as ""ID"", '01' as ""NAME"" FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"", ""NAME"")
|
||||||
|
values (t2.""ID"", t2.""NAME"")", sql);
|
||||||
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new tbioudb02 { id = 1, name = "011" });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOUDB02"" t1
|
||||||
|
USING (SELECT 1 as ""ID"", '011' as ""NAME"" FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"", ""NAME"")
|
||||||
|
values (t2.""ID"", t2.""NAME"")", sql);
|
||||||
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new tbioudb02 { id = 2, name = "02" });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOUDB02"" t1
|
||||||
|
USING (SELECT 2 as ""ID"", '02' as ""NAME"" FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"", ""NAME"")
|
||||||
|
values (t2.""ID"", t2.""NAME"")", sql);
|
||||||
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new[] { new tbioudb02 { id = 1, name = "01" }, new tbioudb02 { id = 2, name = "02" }, new tbioudb02 { id = 3, name = "03" }, new tbioudb02 { id = 4, name = "04" } });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOUDB02"" t1
|
||||||
|
USING (SELECT 1 as ""ID"", '01' as ""NAME"" FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 2, '02' FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 3, '03' FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 4, '04' FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"", ""NAME"")
|
||||||
|
values (t2.""ID"", t2.""NAME"")", sql);
|
||||||
|
Assert.Equal(2, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new[] { new tbioudb02 { id = 1, name = "001" }, new tbioudb02 { id = 2, name = "002" }, new tbioudb02 { id = 3, name = "003" }, new tbioudb02 { id = 4, name = "004" } });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOUDB02"" t1
|
||||||
|
USING (SELECT 1 as ""ID"", '001' as ""NAME"" FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 2, '002' FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 3, '003' FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 4, '004' FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"", ""NAME"")
|
||||||
|
values (t2.""ID"", t2.""NAME"")", sql);
|
||||||
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
|
var lst = fsql.Select<tbioudb02>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
||||||
|
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id).Count());
|
||||||
|
}
|
||||||
|
class tbioudb02
|
||||||
|
{
|
||||||
|
public int id { get; set; }
|
||||||
|
public string name { get; set; }
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void InsertOrUpdate_OnePrimaryAndIdentity()
|
||||||
|
{
|
||||||
|
fsql.Delete<tbioudb022>().Where("1=1").ExecuteAffrows();
|
||||||
|
var iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { id = 1, name = "01" });
|
||||||
|
var sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOUDB022"" t1
|
||||||
|
USING (SELECT 1 as ""ID"", '01' as ""NAME"" FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"", ""NAME"")
|
||||||
|
values (t2.""ID"", t2.""NAME"")", sql);
|
||||||
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { id = 1, name = "011" });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOUDB022"" t1
|
||||||
|
USING (SELECT 1 as ""ID"", '011' as ""NAME"" FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"", ""NAME"")
|
||||||
|
values (t2.""ID"", t2.""NAME"")", sql);
|
||||||
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { id = 2, name = "02" });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOUDB022"" t1
|
||||||
|
USING (SELECT 2 as ""ID"", '02' as ""NAME"" FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"", ""NAME"")
|
||||||
|
values (t2.""ID"", t2.""NAME"")", sql);
|
||||||
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new[] { new tbioudb022 { id = 1, name = "01" }, new tbioudb022 { id = 2, name = "02" }, new tbioudb022 { id = 3, name = "03" }, new tbioudb022 { id = 4, name = "04" } });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOUDB022"" t1
|
||||||
|
USING (SELECT 1 as ""ID"", '01' as ""NAME"" FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 2, '02' FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 3, '03' FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 4, '04' FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"", ""NAME"")
|
||||||
|
values (t2.""ID"", t2.""NAME"")", sql);
|
||||||
|
Assert.Equal(4, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new[] { new tbioudb022 { id = 1, name = "001" }, new tbioudb022 { id = 2, name = "002" }, new tbioudb022 { id = 3, name = "003" }, new tbioudb022 { id = 4, name = "004" } });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOUDB022"" t1
|
||||||
|
USING (SELECT 1 as ""ID"", '001' as ""NAME"" FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 2, '002' FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 3, '003' FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 4, '004' FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"", ""NAME"")
|
||||||
|
values (t2.""ID"", t2.""NAME"")", sql);
|
||||||
|
Assert.Equal(4, iou.ExecuteAffrows());
|
||||||
|
var lst = fsql.Select<tbioudb022>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
||||||
|
//Assert.Equal(4, lst.Where(a => a.name == "00" + a.id).Count());
|
||||||
|
|
||||||
|
//--no primary
|
||||||
|
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { name = "01" });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"INSERT INTO ""TBIOUDB022""(""NAME"") VALUES('01')", sql);
|
||||||
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { name = "011" });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"INSERT INTO ""TBIOUDB022""(""NAME"") VALUES('011')", sql);
|
||||||
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { name = "02" });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"INSERT INTO ""TBIOUDB022""(""NAME"") VALUES('02')", sql);
|
||||||
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new[] { new tbioudb022 { name = "01" }, new tbioudb022 { name = "02" }, new tbioudb022 { name = "03" }, new tbioudb022 { name = "04" } });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"INSERT ALL
|
||||||
|
INTO ""TBIOUDB022""(""NAME"") VALUES('01')
|
||||||
|
INTO ""TBIOUDB022""(""NAME"") VALUES('02')
|
||||||
|
INTO ""TBIOUDB022""(""NAME"") VALUES('03')
|
||||||
|
INTO ""TBIOUDB022""(""NAME"") VALUES('04')
|
||||||
|
SELECT 1 FROM DUAL", sql);
|
||||||
|
Assert.Equal(4, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new[] { new tbioudb022 { name = "001" }, new tbioudb022 { name = "002" }, new tbioudb022 { name = "003" }, new tbioudb022 { name = "004" } });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"INSERT ALL
|
||||||
|
INTO ""TBIOUDB022""(""NAME"") VALUES('001')
|
||||||
|
INTO ""TBIOUDB022""(""NAME"") VALUES('002')
|
||||||
|
INTO ""TBIOUDB022""(""NAME"") VALUES('003')
|
||||||
|
INTO ""TBIOUDB022""(""NAME"") VALUES('004')
|
||||||
|
SELECT 1 FROM DUAL", sql);
|
||||||
|
Assert.Equal(4, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
//--no primary and yes
|
||||||
|
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new[] { new tbioudb022 { id = 1, name = "100001" }, new tbioudb022 { name = "00001" }, new tbioudb022 { id = 2, name = "100002" }, new tbioudb022 { name = "00002" }, new tbioudb022 { id = 3, name = "100003" }, new tbioudb022 { name = "00003" }, new tbioudb022 { id = 4, name = "100004" }, new tbioudb022 { name = "00004" } });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOUDB022"" t1
|
||||||
|
USING (SELECT 1 as ""ID"", '100001' as ""NAME"" FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 2, '100002' FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 3, '100003' FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 4, '100004' FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"", ""NAME"")
|
||||||
|
values (t2.""ID"", t2.""NAME"")
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
INSERT ALL
|
||||||
|
INTO ""TBIOUDB022""(""NAME"") VALUES('00001')
|
||||||
|
INTO ""TBIOUDB022""(""NAME"") VALUES('00002')
|
||||||
|
INTO ""TBIOUDB022""(""NAME"") VALUES('00003')
|
||||||
|
INTO ""TBIOUDB022""(""NAME"") VALUES('00004')
|
||||||
|
SELECT 1 FROM DUAL", sql);
|
||||||
|
Assert.Equal(8, iou.ExecuteAffrows());
|
||||||
|
lst = fsql.Select<tbioudb022>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
||||||
|
//Assert.Equal(4, lst.Where(a => a.name == "10000" + a.id).Count());
|
||||||
|
}
|
||||||
|
class tbioudb022
|
||||||
|
{
|
||||||
|
[Column(IsIdentity = true)]
|
||||||
|
public int id { get; set; }
|
||||||
|
public string name { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void InsertOrUpdate_TwoPrimary()
|
||||||
|
{
|
||||||
|
fsql.Delete<tbioudb03>().Where("1=1").ExecuteAffrows();
|
||||||
|
var iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new tbioudb03 { id1 = 1, id2 = "01", name = "01" });
|
||||||
|
var sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOUDB03"" t1
|
||||||
|
USING (SELECT 1 as ""ID1"", '01' as ""ID2"", '01' as ""NAME"" FROM dual ) t2 ON (t1.""ID1"" = t2.""ID1"" AND t1.""ID2"" = t2.""ID2"")
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID1"", ""ID2"", ""NAME"")
|
||||||
|
values (t2.""ID1"", t2.""ID2"", t2.""NAME"")", sql);
|
||||||
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new tbioudb03 { id1 = 1, id2 = "01", name = "011" });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOUDB03"" t1
|
||||||
|
USING (SELECT 1 as ""ID1"", '01' as ""ID2"", '011' as ""NAME"" FROM dual ) t2 ON (t1.""ID1"" = t2.""ID1"" AND t1.""ID2"" = t2.""ID2"")
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID1"", ""ID2"", ""NAME"")
|
||||||
|
values (t2.""ID1"", t2.""ID2"", t2.""NAME"")", sql);
|
||||||
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new tbioudb03 { id1 = 2, id2 = "02", name = "02" });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOUDB03"" t1
|
||||||
|
USING (SELECT 2 as ""ID1"", '02' as ""ID2"", '02' as ""NAME"" FROM dual ) t2 ON (t1.""ID1"" = t2.""ID1"" AND t1.""ID2"" = t2.""ID2"")
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID1"", ""ID2"", ""NAME"")
|
||||||
|
values (t2.""ID1"", t2.""ID2"", t2.""NAME"")", sql);
|
||||||
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new[] { new tbioudb03 { id1 = 1, id2 = "01", name = "01" }, new tbioudb03 { id1 = 2, id2 = "02", name = "02" }, new tbioudb03 { id1 = 3, id2 = "03", name = "03" }, new tbioudb03 { id1 = 4, id2 = "04", name = "04" } });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOUDB03"" t1
|
||||||
|
USING (SELECT 1 as ""ID1"", '01' as ""ID2"", '01' as ""NAME"" FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 2, '02', '02' FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 3, '03', '03' FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 4, '04', '04' FROM dual ) t2 ON (t1.""ID1"" = t2.""ID1"" AND t1.""ID2"" = t2.""ID2"")
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID1"", ""ID2"", ""NAME"")
|
||||||
|
values (t2.""ID1"", t2.""ID2"", t2.""NAME"")", sql);
|
||||||
|
Assert.Equal(2, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new[] { new tbioudb03 { id1 = 1, id2 = "01", name = "001" }, new tbioudb03 { id1 = 2, id2 = "02", name = "002" }, new tbioudb03 { id1 = 3, id2 = "03", name = "003" }, new tbioudb03 { id1 = 4, id2 = "04", name = "004" } });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOUDB03"" t1
|
||||||
|
USING (SELECT 1 as ""ID1"", '01' as ""ID2"", '001' as ""NAME"" FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 2, '02', '002' FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 3, '03', '003' FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 4, '04', '004' FROM dual ) t2 ON (t1.""ID1"" = t2.""ID1"" AND t1.""ID2"" = t2.""ID2"")
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID1"", ""ID2"", ""NAME"")
|
||||||
|
values (t2.""ID1"", t2.""ID2"", t2.""NAME"")", sql);
|
||||||
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
|
var lst = fsql.Select<tbioudb03>().Where(a => a.id1 == 1 && a.id2 == "01" || a.id1 == 2 && a.id2 == "02" || a.id1 == 3 && a.id2 == "03" || a.id1 == 4 && a.id2 == "04").ToList();
|
||||||
|
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id1).Count());
|
||||||
|
}
|
||||||
|
class tbioudb03
|
||||||
|
{
|
||||||
|
[Column(IsPrimary = true)]
|
||||||
|
public int id1 { get; set; }
|
||||||
|
[Column(IsPrimary = true)]
|
||||||
|
public string id2 { get; set; }
|
||||||
|
public string name { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void InsertOrUpdate_OnePrimaryAndVersionAndCanUpdate()
|
||||||
|
{
|
||||||
|
fsql.Delete<tbioudb04>().Where("1=1").ExecuteAffrows();
|
||||||
|
var iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new tbioudb04 { id = 1, name = "01" });
|
||||||
|
var sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOUDB04"" t1
|
||||||
|
USING (SELECT 1 as ""ID"", '01' as ""NAME"", 0 as ""VERSION"", systimestamp as ""CREATETIME"" FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"", ""NAME"", ""VERSION"", ""CREATETIME"")
|
||||||
|
values (t2.""ID"", t2.""NAME"", t2.""VERSION"", t2.""CREATETIME"")", sql);
|
||||||
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new tbioudb04 { id = 1, name = "011" });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOUDB04"" t1
|
||||||
|
USING (SELECT 1 as ""ID"", '011' as ""NAME"", 0 as ""VERSION"", systimestamp as ""CREATETIME"" FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"", ""NAME"", ""VERSION"", ""CREATETIME"")
|
||||||
|
values (t2.""ID"", t2.""NAME"", t2.""VERSION"", t2.""CREATETIME"")", sql);
|
||||||
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new tbioudb04 { id = 2, name = "02" });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOUDB04"" t1
|
||||||
|
USING (SELECT 2 as ""ID"", '02' as ""NAME"", 0 as ""VERSION"", systimestamp as ""CREATETIME"" FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"", ""NAME"", ""VERSION"", ""CREATETIME"")
|
||||||
|
values (t2.""ID"", t2.""NAME"", t2.""VERSION"", t2.""CREATETIME"")", sql);
|
||||||
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new[] { new tbioudb04 { id = 1, name = "01" }, new tbioudb04 { id = 2, name = "02" }, new tbioudb04 { id = 3, name = "03" }, new tbioudb04 { id = 4, name = "04" } });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOUDB04"" t1
|
||||||
|
USING (SELECT 1 as ""ID"", '01' as ""NAME"", 0 as ""VERSION"", systimestamp as ""CREATETIME"" FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 2, '02', 0, systimestamp FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 3, '03', 0, systimestamp FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 4, '04', 0, systimestamp FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"", ""NAME"", ""VERSION"", ""CREATETIME"")
|
||||||
|
values (t2.""ID"", t2.""NAME"", t2.""VERSION"", t2.""CREATETIME"")", sql);
|
||||||
|
Assert.Equal(2, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new[] { new tbioudb04 { id = 1, name = "001" }, new tbioudb04 { id = 2, name = "002" }, new tbioudb04 { id = 3, name = "003" }, new tbioudb04 { id = 4, name = "004" } });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOUDB04"" t1
|
||||||
|
USING (SELECT 1 as ""ID"", '001' as ""NAME"", 0 as ""VERSION"", systimestamp as ""CREATETIME"" FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 2, '002', 0, systimestamp FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 3, '003', 0, systimestamp FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 4, '004', 0, systimestamp FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"", ""NAME"", ""VERSION"", ""CREATETIME"")
|
||||||
|
values (t2.""ID"", t2.""NAME"", t2.""VERSION"", t2.""CREATETIME"")", sql);
|
||||||
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
|
var lst = fsql.Select<tbioudb04>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
||||||
|
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id).Count());
|
||||||
|
}
|
||||||
|
class tbioudb04
|
||||||
|
{
|
||||||
|
public int id { get; set; }
|
||||||
|
public string name { get; set; }
|
||||||
|
[Column(IsVersion = true)]
|
||||||
|
public int version { get; set; }
|
||||||
|
[Column(CanUpdate = false, ServerTime = DateTimeKind.Local)]
|
||||||
|
public DateTime CreateTime { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,467 @@
|
|||||||
|
using FreeSql.DataAnnotations;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace FreeSql.Tests.OracleOledb
|
||||||
|
{
|
||||||
|
public class OracleOledbInsertOrUpdateTest
|
||||||
|
{
|
||||||
|
IFreeSql fsql => g.oracle;
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void InsertOrUpdate_OnlyPrimary()
|
||||||
|
{
|
||||||
|
fsql.Delete<tbiou01>().Where("1=1").ExecuteAffrows();
|
||||||
|
var iou = fsql.InsertOrUpdate<tbiou01>().SetSource(new tbiou01 { id = 1 });
|
||||||
|
var sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOU01"" t1
|
||||||
|
USING (SELECT 1 as ""ID"" FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"")
|
||||||
|
values (t2.""ID"")", sql);
|
||||||
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbiou01>().SetSource(new tbiou01 { id = 1 });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOU01"" t1
|
||||||
|
USING (SELECT 1 as ""ID"" FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"")
|
||||||
|
values (t2.""ID"")", sql);
|
||||||
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbiou01>().SetSource(new tbiou01 { id = 2 });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOU01"" t1
|
||||||
|
USING (SELECT 2 as ""ID"" FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"")
|
||||||
|
values (t2.""ID"")", sql);
|
||||||
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbiou01>().SetSource(new[] { new tbiou01 { id = 1 }, new tbiou01 { id = 2 }, new tbiou01 { id = 3 }, new tbiou01 { id = 4 } });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOU01"" t1
|
||||||
|
USING (SELECT 1 as ""ID"" FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 2 FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 3 FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 4 FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"")
|
||||||
|
values (t2.""ID"")", sql);
|
||||||
|
Assert.Equal(2, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbiou01>().SetSource(new[] { new tbiou01 { id = 1 }, new tbiou01 { id = 2 }, new tbiou01 { id = 3 }, new tbiou01 { id = 4 } });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOU01"" t1
|
||||||
|
USING (SELECT 1 as ""ID"" FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 2 FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 3 FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 4 FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"")
|
||||||
|
values (t2.""ID"")", sql);
|
||||||
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
|
}
|
||||||
|
class tbiou01
|
||||||
|
{
|
||||||
|
public int id { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void InsertOrUpdate_OnePrimary()
|
||||||
|
{
|
||||||
|
fsql.Delete<tbiou02>().Where("1=1").ExecuteAffrows();
|
||||||
|
var iou = fsql.InsertOrUpdate<tbiou02>().SetSource(new tbiou02 { id = 1, name = "01" });
|
||||||
|
var sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOU02"" t1
|
||||||
|
USING (SELECT 1 as ""ID"", '01' as ""NAME"" FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN MATCHED THEN
|
||||||
|
update set ""NAME"" = t2.""NAME""
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"", ""NAME"")
|
||||||
|
values (t2.""ID"", t2.""NAME"")", sql);
|
||||||
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbiou02>().SetSource(new tbiou02 { id = 1, name = "011" });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOU02"" t1
|
||||||
|
USING (SELECT 1 as ""ID"", '011' as ""NAME"" FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN MATCHED THEN
|
||||||
|
update set ""NAME"" = t2.""NAME""
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"", ""NAME"")
|
||||||
|
values (t2.""ID"", t2.""NAME"")", sql);
|
||||||
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbiou02>().SetSource(new tbiou02 { id = 2, name = "02" });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOU02"" t1
|
||||||
|
USING (SELECT 2 as ""ID"", '02' as ""NAME"" FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN MATCHED THEN
|
||||||
|
update set ""NAME"" = t2.""NAME""
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"", ""NAME"")
|
||||||
|
values (t2.""ID"", t2.""NAME"")", sql);
|
||||||
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbiou02>().SetSource(new[] { new tbiou02 { id = 1, name = "01" }, new tbiou02 { id = 2, name = "02" }, new tbiou02 { id = 3, name = "03" }, new tbiou02 { id = 4, name = "04" } });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOU02"" t1
|
||||||
|
USING (SELECT 1 as ""ID"", '01' as ""NAME"" FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 2, '02' FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 3, '03' FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 4, '04' FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN MATCHED THEN
|
||||||
|
update set ""NAME"" = t2.""NAME""
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"", ""NAME"")
|
||||||
|
values (t2.""ID"", t2.""NAME"")", sql);
|
||||||
|
Assert.Equal(4, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbiou02>().SetSource(new[] { new tbiou02 { id = 1, name = "001" }, new tbiou02 { id = 2, name = "002" }, new tbiou02 { id = 3, name = "003" }, new tbiou02 { id = 4, name = "004" } });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOU02"" t1
|
||||||
|
USING (SELECT 1 as ""ID"", '001' as ""NAME"" FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 2, '002' FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 3, '003' FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 4, '004' FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN MATCHED THEN
|
||||||
|
update set ""NAME"" = t2.""NAME""
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"", ""NAME"")
|
||||||
|
values (t2.""ID"", t2.""NAME"")", sql);
|
||||||
|
Assert.Equal(4, iou.ExecuteAffrows());
|
||||||
|
var lst = fsql.Select<tbiou02>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
||||||
|
Assert.Equal(4, lst.Where(a => a.name == "00" + a.id).Count());
|
||||||
|
}
|
||||||
|
class tbiou02
|
||||||
|
{
|
||||||
|
public int id { get; set; }
|
||||||
|
public string name { get; set; }
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void InsertOrUpdate_OnePrimaryAndIdentity()
|
||||||
|
{
|
||||||
|
fsql.Delete<tbiou022>().Where("1=1").ExecuteAffrows();
|
||||||
|
var iou = fsql.InsertOrUpdate<tbiou022>().SetSource(new tbiou022 { id = 1, name = "01" });
|
||||||
|
var sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOU022"" t1
|
||||||
|
USING (SELECT 1 as ""ID"", '01' as ""NAME"" FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN MATCHED THEN
|
||||||
|
update set ""NAME"" = t2.""NAME""
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"", ""NAME"")
|
||||||
|
values (t2.""ID"", t2.""NAME"")", sql);
|
||||||
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbiou022>().SetSource(new tbiou022 { id = 1, name = "011" });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOU022"" t1
|
||||||
|
USING (SELECT 1 as ""ID"", '011' as ""NAME"" FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN MATCHED THEN
|
||||||
|
update set ""NAME"" = t2.""NAME""
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"", ""NAME"")
|
||||||
|
values (t2.""ID"", t2.""NAME"")", sql);
|
||||||
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbiou022>().SetSource(new tbiou022 { id = 2, name = "02" });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOU022"" t1
|
||||||
|
USING (SELECT 2 as ""ID"", '02' as ""NAME"" FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN MATCHED THEN
|
||||||
|
update set ""NAME"" = t2.""NAME""
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"", ""NAME"")
|
||||||
|
values (t2.""ID"", t2.""NAME"")", sql);
|
||||||
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbiou022>().SetSource(new[] { new tbiou022 { id = 1, name = "01" }, new tbiou022 { id = 2, name = "02" }, new tbiou022 { id = 3, name = "03" }, new tbiou022 { id = 4, name = "04" } });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOU022"" t1
|
||||||
|
USING (SELECT 1 as ""ID"", '01' as ""NAME"" FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 2, '02' FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 3, '03' FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 4, '04' FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN MATCHED THEN
|
||||||
|
update set ""NAME"" = t2.""NAME""
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"", ""NAME"")
|
||||||
|
values (t2.""ID"", t2.""NAME"")", sql);
|
||||||
|
Assert.Equal(4, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbiou022>().SetSource(new[] { new tbiou022 { id = 1, name = "001" }, new tbiou022 { id = 2, name = "002" }, new tbiou022 { id = 3, name = "003" }, new tbiou022 { id = 4, name = "004" } });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOU022"" t1
|
||||||
|
USING (SELECT 1 as ""ID"", '001' as ""NAME"" FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 2, '002' FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 3, '003' FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 4, '004' FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN MATCHED THEN
|
||||||
|
update set ""NAME"" = t2.""NAME""
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"", ""NAME"")
|
||||||
|
values (t2.""ID"", t2.""NAME"")", sql);
|
||||||
|
Assert.Equal(4, iou.ExecuteAffrows());
|
||||||
|
var lst = fsql.Select<tbiou022>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
||||||
|
//Assert.Equal(4, lst.Where(a => a.name == "00" + a.id).Count());
|
||||||
|
|
||||||
|
//--no primary
|
||||||
|
iou = fsql.InsertOrUpdate<tbiou022>().SetSource(new tbiou022 { name = "01" });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"INSERT INTO ""TBIOU022""(""NAME"") VALUES('01')", sql);
|
||||||
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbiou022>().SetSource(new tbiou022 { name = "011" });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"INSERT INTO ""TBIOU022""(""NAME"") VALUES('011')", sql);
|
||||||
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbiou022>().SetSource(new tbiou022 { name = "02" });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"INSERT INTO ""TBIOU022""(""NAME"") VALUES('02')", sql);
|
||||||
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbiou022>().SetSource(new[] { new tbiou022 { name = "01" }, new tbiou022 { name = "02" }, new tbiou022 { name = "03" }, new tbiou022 { name = "04" } });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"INSERT ALL
|
||||||
|
INTO ""TBIOU022""(""NAME"") VALUES('01')
|
||||||
|
INTO ""TBIOU022""(""NAME"") VALUES('02')
|
||||||
|
INTO ""TBIOU022""(""NAME"") VALUES('03')
|
||||||
|
INTO ""TBIOU022""(""NAME"") VALUES('04')
|
||||||
|
SELECT 1 FROM DUAL", sql);
|
||||||
|
Assert.Equal(4, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbiou022>().SetSource(new[] { new tbiou022 { name = "001" }, new tbiou022 { name = "002" }, new tbiou022 { name = "003" }, new tbiou022 { name = "004" } });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"INSERT ALL
|
||||||
|
INTO ""TBIOU022""(""NAME"") VALUES('001')
|
||||||
|
INTO ""TBIOU022""(""NAME"") VALUES('002')
|
||||||
|
INTO ""TBIOU022""(""NAME"") VALUES('003')
|
||||||
|
INTO ""TBIOU022""(""NAME"") VALUES('004')
|
||||||
|
SELECT 1 FROM DUAL", sql);
|
||||||
|
Assert.Equal(4, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
//--no primary and yes
|
||||||
|
iou = fsql.InsertOrUpdate<tbiou022>().SetSource(new[] { new tbiou022 { id = 1, name = "100001" }, new tbiou022 { name = "00001" }, new tbiou022 { id = 2, name = "100002" }, new tbiou022 { name = "00002" }, new tbiou022 { id = 3, name = "100003" }, new tbiou022 { name = "00003" }, new tbiou022 { id = 4, name = "100004" }, new tbiou022 { name = "00004" } });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOU022"" t1
|
||||||
|
USING (SELECT 1 as ""ID"", '100001' as ""NAME"" FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 2, '100002' FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 3, '100003' FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 4, '100004' FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN MATCHED THEN
|
||||||
|
update set ""NAME"" = t2.""NAME""
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"", ""NAME"")
|
||||||
|
values (t2.""ID"", t2.""NAME"")
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
INSERT ALL
|
||||||
|
INTO ""TBIOU022""(""NAME"") VALUES('00001')
|
||||||
|
INTO ""TBIOU022""(""NAME"") VALUES('00002')
|
||||||
|
INTO ""TBIOU022""(""NAME"") VALUES('00003')
|
||||||
|
INTO ""TBIOU022""(""NAME"") VALUES('00004')
|
||||||
|
SELECT 1 FROM DUAL", sql);
|
||||||
|
Assert.Equal(8, iou.ExecuteAffrows());
|
||||||
|
lst = fsql.Select<tbiou022>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
||||||
|
//Assert.Equal(4, lst.Where(a => a.name == "10000" + a.id).Count());
|
||||||
|
}
|
||||||
|
class tbiou022
|
||||||
|
{
|
||||||
|
[Column(IsIdentity = true)]
|
||||||
|
public int id { get; set; }
|
||||||
|
public string name { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void InsertOrUpdate_TwoPrimary()
|
||||||
|
{
|
||||||
|
fsql.Delete<tbiou03>().Where("1=1").ExecuteAffrows();
|
||||||
|
var iou = fsql.InsertOrUpdate<tbiou03>().SetSource(new tbiou03 { id1 = 1, id2 = "01", name = "01" });
|
||||||
|
var sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOU03"" t1
|
||||||
|
USING (SELECT 1 as ""ID1"", '01' as ""ID2"", '01' as ""NAME"" FROM dual ) t2 ON (t1.""ID1"" = t2.""ID1"" AND t1.""ID2"" = t2.""ID2"")
|
||||||
|
WHEN MATCHED THEN
|
||||||
|
update set ""NAME"" = t2.""NAME""
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID1"", ""ID2"", ""NAME"")
|
||||||
|
values (t2.""ID1"", t2.""ID2"", t2.""NAME"")", sql);
|
||||||
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbiou03>().SetSource(new tbiou03 { id1 = 1, id2 = "01", name = "011" });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOU03"" t1
|
||||||
|
USING (SELECT 1 as ""ID1"", '01' as ""ID2"", '011' as ""NAME"" FROM dual ) t2 ON (t1.""ID1"" = t2.""ID1"" AND t1.""ID2"" = t2.""ID2"")
|
||||||
|
WHEN MATCHED THEN
|
||||||
|
update set ""NAME"" = t2.""NAME""
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID1"", ""ID2"", ""NAME"")
|
||||||
|
values (t2.""ID1"", t2.""ID2"", t2.""NAME"")", sql);
|
||||||
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbiou03>().SetSource(new tbiou03 { id1 = 2, id2 = "02", name = "02" });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOU03"" t1
|
||||||
|
USING (SELECT 2 as ""ID1"", '02' as ""ID2"", '02' as ""NAME"" FROM dual ) t2 ON (t1.""ID1"" = t2.""ID1"" AND t1.""ID2"" = t2.""ID2"")
|
||||||
|
WHEN MATCHED THEN
|
||||||
|
update set ""NAME"" = t2.""NAME""
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID1"", ""ID2"", ""NAME"")
|
||||||
|
values (t2.""ID1"", t2.""ID2"", t2.""NAME"")", sql);
|
||||||
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbiou03>().SetSource(new[] { new tbiou03 { id1 = 1, id2 = "01", name = "01" }, new tbiou03 { id1 = 2, id2 = "02", name = "02" }, new tbiou03 { id1 = 3, id2 = "03", name = "03" }, new tbiou03 { id1 = 4, id2 = "04", name = "04" } });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOU03"" t1
|
||||||
|
USING (SELECT 1 as ""ID1"", '01' as ""ID2"", '01' as ""NAME"" FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 2, '02', '02' FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 3, '03', '03' FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 4, '04', '04' FROM dual ) t2 ON (t1.""ID1"" = t2.""ID1"" AND t1.""ID2"" = t2.""ID2"")
|
||||||
|
WHEN MATCHED THEN
|
||||||
|
update set ""NAME"" = t2.""NAME""
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID1"", ""ID2"", ""NAME"")
|
||||||
|
values (t2.""ID1"", t2.""ID2"", t2.""NAME"")", sql);
|
||||||
|
Assert.Equal(4, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbiou03>().SetSource(new[] { new tbiou03 { id1 = 1, id2 = "01", name = "001" }, new tbiou03 { id1 = 2, id2 = "02", name = "002" }, new tbiou03 { id1 = 3, id2 = "03", name = "003" }, new tbiou03 { id1 = 4, id2 = "04", name = "004" } });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOU03"" t1
|
||||||
|
USING (SELECT 1 as ""ID1"", '01' as ""ID2"", '001' as ""NAME"" FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 2, '02', '002' FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 3, '03', '003' FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 4, '04', '004' FROM dual ) t2 ON (t1.""ID1"" = t2.""ID1"" AND t1.""ID2"" = t2.""ID2"")
|
||||||
|
WHEN MATCHED THEN
|
||||||
|
update set ""NAME"" = t2.""NAME""
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID1"", ""ID2"", ""NAME"")
|
||||||
|
values (t2.""ID1"", t2.""ID2"", t2.""NAME"")", sql);
|
||||||
|
Assert.Equal(4, iou.ExecuteAffrows());
|
||||||
|
var lst = fsql.Select<tbiou03>().Where(a => a.id1 == 1 && a.id2 == "01" || a.id1 == 2 && a.id2 == "02" || a.id1 == 3 && a.id2 == "03" || a.id1 == 4 && a.id2 == "04").ToList();
|
||||||
|
Assert.Equal(4, lst.Where(a => a.name == "00" + a.id1).Count());
|
||||||
|
}
|
||||||
|
class tbiou03
|
||||||
|
{
|
||||||
|
[Column(IsPrimary = true)]
|
||||||
|
public int id1 { get; set; }
|
||||||
|
[Column(IsPrimary = true)]
|
||||||
|
public string id2 { get; set; }
|
||||||
|
public string name { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void InsertOrUpdate_OnePrimaryAndVersionAndCanUpdate()
|
||||||
|
{
|
||||||
|
fsql.Delete<tbiou04>().Where("1=1").ExecuteAffrows();
|
||||||
|
var iou = fsql.InsertOrUpdate<tbiou04>().SetSource(new tbiou04 { id = 1, name = "01" });
|
||||||
|
var sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOU04"" t1
|
||||||
|
USING (SELECT 1 as ""ID"", '01' as ""NAME"", 0 as ""VERSION"", systimestamp as ""CREATETIME"" FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN MATCHED THEN
|
||||||
|
update set ""NAME"" = t2.""NAME"", ""VERSION"" = t1.""VERSION"" + 1
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"", ""NAME"", ""VERSION"", ""CREATETIME"")
|
||||||
|
values (t2.""ID"", t2.""NAME"", t2.""VERSION"", t2.""CREATETIME"")", sql);
|
||||||
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbiou04>().SetSource(new tbiou04 { id = 1, name = "011" });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOU04"" t1
|
||||||
|
USING (SELECT 1 as ""ID"", '011' as ""NAME"", 0 as ""VERSION"", systimestamp as ""CREATETIME"" FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN MATCHED THEN
|
||||||
|
update set ""NAME"" = t2.""NAME"", ""VERSION"" = t1.""VERSION"" + 1
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"", ""NAME"", ""VERSION"", ""CREATETIME"")
|
||||||
|
values (t2.""ID"", t2.""NAME"", t2.""VERSION"", t2.""CREATETIME"")", sql);
|
||||||
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbiou04>().SetSource(new tbiou04 { id = 2, name = "02" });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOU04"" t1
|
||||||
|
USING (SELECT 2 as ""ID"", '02' as ""NAME"", 0 as ""VERSION"", systimestamp as ""CREATETIME"" FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN MATCHED THEN
|
||||||
|
update set ""NAME"" = t2.""NAME"", ""VERSION"" = t1.""VERSION"" + 1
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"", ""NAME"", ""VERSION"", ""CREATETIME"")
|
||||||
|
values (t2.""ID"", t2.""NAME"", t2.""VERSION"", t2.""CREATETIME"")", sql);
|
||||||
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbiou04>().SetSource(new[] { new tbiou04 { id = 1, name = "01" }, new tbiou04 { id = 2, name = "02" }, new tbiou04 { id = 3, name = "03" }, new tbiou04 { id = 4, name = "04" } });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOU04"" t1
|
||||||
|
USING (SELECT 1 as ""ID"", '01' as ""NAME"", 0 as ""VERSION"", systimestamp as ""CREATETIME"" FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 2, '02', 0, systimestamp FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 3, '03', 0, systimestamp FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 4, '04', 0, systimestamp FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN MATCHED THEN
|
||||||
|
update set ""NAME"" = t2.""NAME"", ""VERSION"" = t1.""VERSION"" + 1
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"", ""NAME"", ""VERSION"", ""CREATETIME"")
|
||||||
|
values (t2.""ID"", t2.""NAME"", t2.""VERSION"", t2.""CREATETIME"")", sql);
|
||||||
|
Assert.Equal(4, iou.ExecuteAffrows());
|
||||||
|
|
||||||
|
iou = fsql.InsertOrUpdate<tbiou04>().SetSource(new[] { new tbiou04 { id = 1, name = "001" }, new tbiou04 { id = 2, name = "002" }, new tbiou04 { id = 3, name = "003" }, new tbiou04 { id = 4, name = "004" } });
|
||||||
|
sql = iou.ToSql();
|
||||||
|
Assert.Equal(@"MERGE INTO ""TBIOU04"" t1
|
||||||
|
USING (SELECT 1 as ""ID"", '001' as ""NAME"", 0 as ""VERSION"", systimestamp as ""CREATETIME"" FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 2, '002', 0, systimestamp FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 3, '003', 0, systimestamp FROM dual
|
||||||
|
UNION ALL
|
||||||
|
SELECT 4, '004', 0, systimestamp FROM dual ) t2 ON (t1.""ID"" = t2.""ID"")
|
||||||
|
WHEN MATCHED THEN
|
||||||
|
update set ""NAME"" = t2.""NAME"", ""VERSION"" = t1.""VERSION"" + 1
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
insert (""ID"", ""NAME"", ""VERSION"", ""CREATETIME"")
|
||||||
|
values (t2.""ID"", t2.""NAME"", t2.""VERSION"", t2.""CREATETIME"")", sql);
|
||||||
|
Assert.Equal(4, iou.ExecuteAffrows());
|
||||||
|
var lst = fsql.Select<tbiou04>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
||||||
|
Assert.Equal(4, lst.Where(a => a.name == "00" + a.id).Count());
|
||||||
|
}
|
||||||
|
class tbiou04
|
||||||
|
{
|
||||||
|
public int id { get; set; }
|
||||||
|
public string name { get; set; }
|
||||||
|
[Column(IsVersion = true)]
|
||||||
|
public int version { get; set; }
|
||||||
|
[Column(CanUpdate = false, ServerTime = DateTimeKind.Local)]
|
||||||
|
public DateTime CreateTime { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,341 @@
|
|||||||
|
using FreeSql.DataAnnotations;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace FreeSql.Tests.OracleOledb
|
||||||
|
{
|
||||||
|
public class OracleOledbInsertTest
|
||||||
|
{
|
||||||
|
|
||||||
|
IInsert<Topic> insert => g.oracle.Insert<Topic>(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
[Table(Name = "tb_topic_insert")]
|
||||||
|
class Topic
|
||||||
|
{
|
||||||
|
[Column(IsIdentity = true, IsPrimary = true)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int? Clicks { get; set; }
|
||||||
|
public string Title { get; set; }
|
||||||
|
public DateTime CreateTime { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void InsertDictionary()
|
||||||
|
{
|
||||||
|
var fsql = g.oracle;
|
||||||
|
Dictionary<string, object> dic = new Dictionary<string, object>();
|
||||||
|
dic.Add("id", 1);
|
||||||
|
dic.Add("name", "xxxx");
|
||||||
|
var diclist = new List<Dictionary<string, object>>();
|
||||||
|
diclist.Add(dic);
|
||||||
|
diclist.Add(new Dictionary<string, object>
|
||||||
|
{
|
||||||
|
["id"] = 2,
|
||||||
|
["name"] = "yyyy"
|
||||||
|
});
|
||||||
|
|
||||||
|
var sql1 = fsql.InsertDict(dic).AsTable("table1").ToSql();
|
||||||
|
Assert.Equal(@"INSERT INTO ""TABLE1""(""ID"", ""NAME"") VALUES(:id_0, :name_0)", sql1);
|
||||||
|
var sql2 = fsql.InsertDict(diclist).AsTable("table1").ToSql();
|
||||||
|
Assert.Equal(@"INSERT ALL
|
||||||
|
INTO ""TABLE1""(""ID"", ""NAME"") VALUES(:id_0, :name_0)
|
||||||
|
INTO ""TABLE1""(""ID"", ""NAME"") VALUES(:id_1, :name_1)
|
||||||
|
SELECT 1 FROM DUAL", sql2);
|
||||||
|
var sql3 = fsql.InsertDict(dic).AsTable("table1").NoneParameter().ToSql();
|
||||||
|
Assert.Equal(@"INSERT INTO ""TABLE1""(""ID"", ""NAME"") VALUES(1, 'xxxx')", sql3);
|
||||||
|
var sql4 = fsql.InsertDict(diclist).AsTable("table1").NoneParameter().ToSql();
|
||||||
|
Assert.Equal(@"INSERT ALL
|
||||||
|
INTO ""TABLE1""(""ID"", ""NAME"") VALUES(1, 'xxxx')
|
||||||
|
INTO ""TABLE1""(""ID"", ""NAME"") VALUES(2, 'yyyy')
|
||||||
|
SELECT 1 FROM DUAL", sql4);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void AppendData()
|
||||||
|
{
|
||||||
|
var items = new List<Topic>();
|
||||||
|
for (var a = 0; a < 10; a++) items.Add(new Topic { Id = a + 1, Title = $"newtitle{a}", Clicks = a * 100, CreateTime = DateTime.Now });
|
||||||
|
|
||||||
|
var data = new List<object>();
|
||||||
|
var sql = insert.AppendData(items.First()).ToSql();
|
||||||
|
Assert.Equal("INSERT INTO \"TB_TOPIC_INSERT\"(\"CLICKS\", \"TITLE\", \"CREATETIME\") VALUES(:Clicks_0, :Title_0, :CreateTime_0)", sql);
|
||||||
|
data.Add(insert.AppendData(items.First()).ExecuteIdentity());
|
||||||
|
|
||||||
|
sql = insert.AppendData(items).ToSql();
|
||||||
|
Assert.Equal(@"INSERT ALL
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"", ""TITLE"", ""CREATETIME"") VALUES(:Clicks_0, :Title_0, :CreateTime_0)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"", ""TITLE"", ""CREATETIME"") VALUES(:Clicks_1, :Title_1, :CreateTime_1)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"", ""TITLE"", ""CREATETIME"") VALUES(:Clicks_2, :Title_2, :CreateTime_2)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"", ""TITLE"", ""CREATETIME"") VALUES(:Clicks_3, :Title_3, :CreateTime_3)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"", ""TITLE"", ""CREATETIME"") VALUES(:Clicks_4, :Title_4, :CreateTime_4)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"", ""TITLE"", ""CREATETIME"") VALUES(:Clicks_5, :Title_5, :CreateTime_5)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"", ""TITLE"", ""CREATETIME"") VALUES(:Clicks_6, :Title_6, :CreateTime_6)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"", ""TITLE"", ""CREATETIME"") VALUES(:Clicks_7, :Title_7, :CreateTime_7)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"", ""TITLE"", ""CREATETIME"") VALUES(:Clicks_8, :Title_8, :CreateTime_8)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"", ""TITLE"", ""CREATETIME"") VALUES(:Clicks_9, :Title_9, :CreateTime_9)
|
||||||
|
SELECT 1 FROM DUAL", sql);
|
||||||
|
data.Add(insert.AppendData(items.First()).ExecuteIdentity());
|
||||||
|
|
||||||
|
sql = insert.AppendData(items).InsertColumns(a => a.Title).ToSql();
|
||||||
|
Assert.Equal(@"INSERT ALL
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""TITLE"") VALUES(:Title_0)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""TITLE"") VALUES(:Title_1)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""TITLE"") VALUES(:Title_2)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""TITLE"") VALUES(:Title_3)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""TITLE"") VALUES(:Title_4)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""TITLE"") VALUES(:Title_5)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""TITLE"") VALUES(:Title_6)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""TITLE"") VALUES(:Title_7)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""TITLE"") VALUES(:Title_8)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""TITLE"") VALUES(:Title_9)
|
||||||
|
SELECT 1 FROM DUAL", sql);
|
||||||
|
data.Add(insert.AppendData(items.First()).ExecuteIdentity());
|
||||||
|
|
||||||
|
sql = insert.AppendData(items).IgnoreColumns(a => a.CreateTime).ToSql();
|
||||||
|
Assert.Equal(@"INSERT ALL
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"", ""TITLE"") VALUES(:Clicks_0, :Title_0)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"", ""TITLE"") VALUES(:Clicks_1, :Title_1)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"", ""TITLE"") VALUES(:Clicks_2, :Title_2)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"", ""TITLE"") VALUES(:Clicks_3, :Title_3)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"", ""TITLE"") VALUES(:Clicks_4, :Title_4)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"", ""TITLE"") VALUES(:Clicks_5, :Title_5)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"", ""TITLE"") VALUES(:Clicks_6, :Title_6)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"", ""TITLE"") VALUES(:Clicks_7, :Title_7)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"", ""TITLE"") VALUES(:Clicks_8, :Title_8)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"", ""TITLE"") VALUES(:Clicks_9, :Title_9)
|
||||||
|
SELECT 1 FROM DUAL", sql);
|
||||||
|
data.Add(insert.AppendData(items.First()).ExecuteIdentity());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void InsertColumns()
|
||||||
|
{
|
||||||
|
var items = new List<Topic>();
|
||||||
|
for (var a = 0; a < 10; a++) items.Add(new Topic { Id = a + 1, Title = $"newtitle{a}", Clicks = a * 100, CreateTime = DateTime.Now });
|
||||||
|
|
||||||
|
var data = new List<object>();
|
||||||
|
var sql = insert.AppendData(items).InsertColumns(a => a.Title).ToSql();
|
||||||
|
Assert.Equal(@"INSERT ALL
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""TITLE"") VALUES(:Title_0)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""TITLE"") VALUES(:Title_1)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""TITLE"") VALUES(:Title_2)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""TITLE"") VALUES(:Title_3)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""TITLE"") VALUES(:Title_4)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""TITLE"") VALUES(:Title_5)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""TITLE"") VALUES(:Title_6)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""TITLE"") VALUES(:Title_7)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""TITLE"") VALUES(:Title_8)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""TITLE"") VALUES(:Title_9)
|
||||||
|
SELECT 1 FROM DUAL", sql);
|
||||||
|
data.Add(insert.AppendData(items.First()).ExecuteIdentity());
|
||||||
|
|
||||||
|
sql = insert.AppendData(items).InsertColumns(a => new { a.Title, a.Clicks }).ToSql();
|
||||||
|
Assert.Equal(@"INSERT ALL
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"", ""TITLE"") VALUES(:Clicks_0, :Title_0)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"", ""TITLE"") VALUES(:Clicks_1, :Title_1)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"", ""TITLE"") VALUES(:Clicks_2, :Title_2)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"", ""TITLE"") VALUES(:Clicks_3, :Title_3)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"", ""TITLE"") VALUES(:Clicks_4, :Title_4)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"", ""TITLE"") VALUES(:Clicks_5, :Title_5)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"", ""TITLE"") VALUES(:Clicks_6, :Title_6)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"", ""TITLE"") VALUES(:Clicks_7, :Title_7)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"", ""TITLE"") VALUES(:Clicks_8, :Title_8)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"", ""TITLE"") VALUES(:Clicks_9, :Title_9)
|
||||||
|
SELECT 1 FROM DUAL", sql);
|
||||||
|
data.Add(insert.AppendData(items.First()).ExecuteIdentity());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void IgnoreColumns()
|
||||||
|
{
|
||||||
|
var items = new List<Topic>();
|
||||||
|
for (var a = 0; a < 10; a++) items.Add(new Topic { Id = a + 1, Title = $"newtitle{a}", Clicks = a * 100, CreateTime = DateTime.Now });
|
||||||
|
|
||||||
|
var data = new List<object>();
|
||||||
|
var sql = insert.AppendData(items).IgnoreColumns(a => a.CreateTime).ToSql();
|
||||||
|
Assert.Equal(@"INSERT ALL
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"", ""TITLE"") VALUES(:Clicks_0, :Title_0)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"", ""TITLE"") VALUES(:Clicks_1, :Title_1)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"", ""TITLE"") VALUES(:Clicks_2, :Title_2)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"", ""TITLE"") VALUES(:Clicks_3, :Title_3)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"", ""TITLE"") VALUES(:Clicks_4, :Title_4)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"", ""TITLE"") VALUES(:Clicks_5, :Title_5)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"", ""TITLE"") VALUES(:Clicks_6, :Title_6)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"", ""TITLE"") VALUES(:Clicks_7, :Title_7)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"", ""TITLE"") VALUES(:Clicks_8, :Title_8)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"", ""TITLE"") VALUES(:Clicks_9, :Title_9)
|
||||||
|
SELECT 1 FROM DUAL", sql);
|
||||||
|
data.Add(insert.AppendData(items.First()).ExecuteIdentity());
|
||||||
|
|
||||||
|
sql = insert.AppendData(items).IgnoreColumns(a => new { a.Title, a.CreateTime }).ToSql();
|
||||||
|
Assert.Equal(@"INSERT ALL
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"") VALUES(:Clicks_0)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"") VALUES(:Clicks_1)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"") VALUES(:Clicks_2)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"") VALUES(:Clicks_3)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"") VALUES(:Clicks_4)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"") VALUES(:Clicks_5)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"") VALUES(:Clicks_6)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"") VALUES(:Clicks_7)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"") VALUES(:Clicks_8)
|
||||||
|
INTO ""TB_TOPIC_INSERT""(""CLICKS"") VALUES(:Clicks_9)
|
||||||
|
SELECT 1 FROM DUAL", sql);
|
||||||
|
data.Add(insert.AppendData(items.First()).ExecuteIdentity());
|
||||||
|
|
||||||
|
g.oracle.Delete<TopicIgnore>().Where("1=1").ExecuteAffrows();
|
||||||
|
var itemsIgnore = new List<TopicIgnore>();
|
||||||
|
for (var a = 0; a < 2072; a++) itemsIgnore.Add(new TopicIgnore { Id = a + 1, Title = $"newtitle{a}", Clicks = a * 100, CreateTime = DateTime.Now });
|
||||||
|
g.oracle.Insert<TopicIgnore>().AppendData(itemsIgnore).IgnoreColumns(a => new { a.Title }).ExecuteAffrows();
|
||||||
|
Assert.Equal(2072, itemsIgnore.Count);
|
||||||
|
Assert.Equal(2072, g.oracle.Select<TopicIgnore>().Where(a => a.Title == null).Count());
|
||||||
|
}
|
||||||
|
[Table(Name = "tb_topicICs")]
|
||||||
|
class TopicIgnore
|
||||||
|
{
|
||||||
|
[Column(IsIdentity = true, IsPrimary = true)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int Clicks { get; set; }
|
||||||
|
public string Title { get; set; }
|
||||||
|
public DateTime CreateTime { get; set; }
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void ExecuteAffrows()
|
||||||
|
{
|
||||||
|
var items = new List<Topic>();
|
||||||
|
for (var a = 0; a < 10; a++) items.Add(new Topic { Id = a + 1, Title = $"newtitle{a}", Clicks = a * 100, CreateTime = DateTime.Now });
|
||||||
|
|
||||||
|
Assert.Equal(1, insert.AppendData(items.First()).ExecuteAffrows());
|
||||||
|
Assert.Equal(10, insert.AppendData(items).ExecuteAffrows());
|
||||||
|
|
||||||
|
Assert.Equal(10, g.oracle.Select<Topic>().Limit(10).InsertInto(null, a => new Topic
|
||||||
|
{
|
||||||
|
Title = a.Title
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void ExecuteIdentity()
|
||||||
|
{
|
||||||
|
var items = new List<Topic>();
|
||||||
|
for (var a = 0; a < 10; a++) items.Add(new Topic { Id = a + 1, Title = $"newtitle{a}", Clicks = a * 100, CreateTime = DateTime.Now });
|
||||||
|
|
||||||
|
Assert.NotEqual(0, insert.AppendData(items.First()).ExecuteIdentity());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void ExecuteInserted()
|
||||||
|
{
|
||||||
|
//var items = new List<Topic>();
|
||||||
|
//for (var a = 0; a < 10; a++) items.Add(new Topic { Id = a + 1, Title = $"newtitle{a}", Clicks = a * 100, CreateTime = DateTime.Now });
|
||||||
|
|
||||||
|
//var items2 = insert.AppendData(items).ExecuteInserted();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void AsTable()
|
||||||
|
{
|
||||||
|
var items = new List<Topic>();
|
||||||
|
for (var a = 0; a < 10; a++) items.Add(new Topic { Id = a + 1, Title = $"newTitle{a}", Clicks = a * 100 });
|
||||||
|
|
||||||
|
var sql = insert.AppendData(items.First()).AsTable(a => "Topic_InsertAsTable").ToSql();
|
||||||
|
Assert.Equal("INSERT INTO \"TOPIC_INSERTASTABLE\"(\"CLICKS\", \"TITLE\", \"CREATETIME\") VALUES(:Clicks_0, :Title_0, :CreateTime_0)", sql);
|
||||||
|
|
||||||
|
sql = insert.AppendData(items).AsTable(a => "Topic_InsertAsTable").ToSql();
|
||||||
|
Assert.Equal(@"INSERT ALL
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"", ""TITLE"", ""CREATETIME"") VALUES(:Clicks_0, :Title_0, :CreateTime_0)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"", ""TITLE"", ""CREATETIME"") VALUES(:Clicks_1, :Title_1, :CreateTime_1)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"", ""TITLE"", ""CREATETIME"") VALUES(:Clicks_2, :Title_2, :CreateTime_2)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"", ""TITLE"", ""CREATETIME"") VALUES(:Clicks_3, :Title_3, :CreateTime_3)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"", ""TITLE"", ""CREATETIME"") VALUES(:Clicks_4, :Title_4, :CreateTime_4)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"", ""TITLE"", ""CREATETIME"") VALUES(:Clicks_5, :Title_5, :CreateTime_5)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"", ""TITLE"", ""CREATETIME"") VALUES(:Clicks_6, :Title_6, :CreateTime_6)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"", ""TITLE"", ""CREATETIME"") VALUES(:Clicks_7, :Title_7, :CreateTime_7)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"", ""TITLE"", ""CREATETIME"") VALUES(:Clicks_8, :Title_8, :CreateTime_8)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"", ""TITLE"", ""CREATETIME"") VALUES(:Clicks_9, :Title_9, :CreateTime_9)
|
||||||
|
SELECT 1 FROM DUAL", sql);
|
||||||
|
|
||||||
|
sql = insert.AppendData(items).InsertColumns(a => a.Title).AsTable(a => "Topic_InsertAsTable").ToSql();
|
||||||
|
Assert.Equal(@"INSERT ALL
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""TITLE"") VALUES(:Title_0)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""TITLE"") VALUES(:Title_1)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""TITLE"") VALUES(:Title_2)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""TITLE"") VALUES(:Title_3)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""TITLE"") VALUES(:Title_4)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""TITLE"") VALUES(:Title_5)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""TITLE"") VALUES(:Title_6)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""TITLE"") VALUES(:Title_7)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""TITLE"") VALUES(:Title_8)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""TITLE"") VALUES(:Title_9)
|
||||||
|
SELECT 1 FROM DUAL", sql);
|
||||||
|
|
||||||
|
sql = insert.AppendData(items).IgnoreColumns(a => a.CreateTime).AsTable(a => "Topic_InsertAsTable").ToSql();
|
||||||
|
Assert.Equal(@"INSERT ALL
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"", ""TITLE"") VALUES(:Clicks_0, :Title_0)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"", ""TITLE"") VALUES(:Clicks_1, :Title_1)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"", ""TITLE"") VALUES(:Clicks_2, :Title_2)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"", ""TITLE"") VALUES(:Clicks_3, :Title_3)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"", ""TITLE"") VALUES(:Clicks_4, :Title_4)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"", ""TITLE"") VALUES(:Clicks_5, :Title_5)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"", ""TITLE"") VALUES(:Clicks_6, :Title_6)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"", ""TITLE"") VALUES(:Clicks_7, :Title_7)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"", ""TITLE"") VALUES(:Clicks_8, :Title_8)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"", ""TITLE"") VALUES(:Clicks_9, :Title_9)
|
||||||
|
SELECT 1 FROM DUAL", sql);
|
||||||
|
|
||||||
|
sql = insert.AppendData(items).InsertColumns(a => a.Title).AsTable(a => "Topic_InsertAsTable").ToSql();
|
||||||
|
Assert.Equal(@"INSERT ALL
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""TITLE"") VALUES(:Title_0)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""TITLE"") VALUES(:Title_1)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""TITLE"") VALUES(:Title_2)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""TITLE"") VALUES(:Title_3)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""TITLE"") VALUES(:Title_4)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""TITLE"") VALUES(:Title_5)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""TITLE"") VALUES(:Title_6)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""TITLE"") VALUES(:Title_7)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""TITLE"") VALUES(:Title_8)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""TITLE"") VALUES(:Title_9)
|
||||||
|
SELECT 1 FROM DUAL", sql);
|
||||||
|
|
||||||
|
sql = insert.AppendData(items).InsertColumns(a => new { a.Title, a.Clicks }).AsTable(a => "Topic_InsertAsTable").ToSql();
|
||||||
|
Assert.Equal(@"INSERT ALL
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"", ""TITLE"") VALUES(:Clicks_0, :Title_0)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"", ""TITLE"") VALUES(:Clicks_1, :Title_1)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"", ""TITLE"") VALUES(:Clicks_2, :Title_2)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"", ""TITLE"") VALUES(:Clicks_3, :Title_3)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"", ""TITLE"") VALUES(:Clicks_4, :Title_4)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"", ""TITLE"") VALUES(:Clicks_5, :Title_5)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"", ""TITLE"") VALUES(:Clicks_6, :Title_6)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"", ""TITLE"") VALUES(:Clicks_7, :Title_7)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"", ""TITLE"") VALUES(:Clicks_8, :Title_8)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"", ""TITLE"") VALUES(:Clicks_9, :Title_9)
|
||||||
|
SELECT 1 FROM DUAL", sql);
|
||||||
|
|
||||||
|
sql = insert.AppendData(items).IgnoreColumns(a => a.CreateTime).AsTable(a => "Topic_InsertAsTable").ToSql();
|
||||||
|
Assert.Equal(@"INSERT ALL
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"", ""TITLE"") VALUES(:Clicks_0, :Title_0)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"", ""TITLE"") VALUES(:Clicks_1, :Title_1)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"", ""TITLE"") VALUES(:Clicks_2, :Title_2)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"", ""TITLE"") VALUES(:Clicks_3, :Title_3)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"", ""TITLE"") VALUES(:Clicks_4, :Title_4)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"", ""TITLE"") VALUES(:Clicks_5, :Title_5)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"", ""TITLE"") VALUES(:Clicks_6, :Title_6)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"", ""TITLE"") VALUES(:Clicks_7, :Title_7)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"", ""TITLE"") VALUES(:Clicks_8, :Title_8)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"", ""TITLE"") VALUES(:Clicks_9, :Title_9)
|
||||||
|
SELECT 1 FROM DUAL", sql);
|
||||||
|
|
||||||
|
sql = insert.AppendData(items).IgnoreColumns(a => new { a.Title, a.CreateTime }).AsTable(a => "Topic_InsertAsTable").ToSql();
|
||||||
|
Assert.Equal(@"INSERT ALL
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"") VALUES(:Clicks_0)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"") VALUES(:Clicks_1)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"") VALUES(:Clicks_2)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"") VALUES(:Clicks_3)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"") VALUES(:Clicks_4)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"") VALUES(:Clicks_5)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"") VALUES(:Clicks_6)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"") VALUES(:Clicks_7)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"") VALUES(:Clicks_8)
|
||||||
|
INTO ""TOPIC_INSERTASTABLE""(""CLICKS"") VALUES(:Clicks_9)
|
||||||
|
SELECT 1 FROM DUAL", sql);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,194 @@
|
|||||||
|
using FreeSql.DataAnnotations;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace FreeSql.Tests.OracleOledb
|
||||||
|
{
|
||||||
|
public class OracleOledbUpdateTest
|
||||||
|
{
|
||||||
|
IUpdate<Topic> update => g.oracle.Update<Topic>();
|
||||||
|
|
||||||
|
[Table(Name = "tb_topic")]
|
||||||
|
class Topic
|
||||||
|
{
|
||||||
|
[Column(IsIdentity = true, IsPrimary = true)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int? Clicks { get; set; }
|
||||||
|
public string Title { get; set; }
|
||||||
|
public DateTime CreateTime { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Dywhere()
|
||||||
|
{
|
||||||
|
Assert.Null(g.oracle.Update<Topic>().ToSql());
|
||||||
|
Assert.Equal("UPDATE \"TB_TOPIC\" SET title='test' \r\nWHERE (\"ID\" IN (1,2))", g.oracle.Update<Topic>(new[] { 1, 2 }).SetRaw("title='test'").ToSql());
|
||||||
|
Assert.Equal("UPDATE \"TB_TOPIC\" SET title='test1' \r\nWHERE (\"ID\" = 1)", g.oracle.Update<Topic>(new Topic { Id = 1, Title = "test" }).SetRaw("title='test1'").ToSql());
|
||||||
|
Assert.Equal("UPDATE \"TB_TOPIC\" SET title='test1' \r\nWHERE (\"ID\" IN (1,2))", g.oracle.Update<Topic>(new[] { new Topic { Id = 1, Title = "test" }, new Topic { Id = 2, Title = "test" } }).SetRaw("title='test1'").ToSql());
|
||||||
|
Assert.Equal("UPDATE \"TB_TOPIC\" SET title='test1' \r\nWHERE (\"ID\" = 1)", g.oracle.Update<Topic>(new { id = 1 }).SetRaw("title='test1'").ToSql());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void SetSource()
|
||||||
|
{
|
||||||
|
var sql = update.SetSource(new Topic { Id = 1, Title = "newtitle" }).ToSql().Replace("\r\n", "");
|
||||||
|
Assert.Equal("UPDATE \"TB_TOPIC\" SET \"CLICKS\" = :p_0, \"TITLE\" = :p_1, \"CREATETIME\" = :p_2 WHERE (\"ID\" = 1)", sql);
|
||||||
|
|
||||||
|
var items = new List<Topic>();
|
||||||
|
for (var a = 0; a < 10; a++) items.Add(new Topic { Id = a + 1, Title = $"newtitle{a}", Clicks = a * 100 });
|
||||||
|
items[0].Clicks = null;
|
||||||
|
|
||||||
|
sql = update.SetSource(items).ToSql().Replace("\r\n", "");
|
||||||
|
Assert.Equal("UPDATE \"TB_TOPIC\" SET \"CLICKS\" = CASE \"ID\" WHEN 1 THEN :p_0 WHEN 2 THEN :p_1 WHEN 3 THEN :p_2 WHEN 4 THEN :p_3 WHEN 5 THEN :p_4 WHEN 6 THEN :p_5 WHEN 7 THEN :p_6 WHEN 8 THEN :p_7 WHEN 9 THEN :p_8 WHEN 10 THEN :p_9 END, \"TITLE\" = CASE \"ID\" WHEN 1 THEN :p_10 WHEN 2 THEN :p_11 WHEN 3 THEN :p_12 WHEN 4 THEN :p_13 WHEN 5 THEN :p_14 WHEN 6 THEN :p_15 WHEN 7 THEN :p_16 WHEN 8 THEN :p_17 WHEN 9 THEN :p_18 WHEN 10 THEN :p_19 END, \"CREATETIME\" = CASE \"ID\" WHEN 1 THEN :p_20 WHEN 2 THEN :p_21 WHEN 3 THEN :p_22 WHEN 4 THEN :p_23 WHEN 5 THEN :p_24 WHEN 6 THEN :p_25 WHEN 7 THEN :p_26 WHEN 8 THEN :p_27 WHEN 9 THEN :p_28 WHEN 10 THEN :p_29 END WHERE (\"ID\" IN (1,2,3,4,5,6,7,8,9,10))", sql);
|
||||||
|
|
||||||
|
sql = update.SetSource(items).IgnoreColumns(a => new { a.Clicks, a.CreateTime }).ToSql().Replace("\r\n", "");
|
||||||
|
Assert.Equal("UPDATE \"TB_TOPIC\" SET \"TITLE\" = CASE \"ID\" WHEN 1 THEN :p_0 WHEN 2 THEN :p_1 WHEN 3 THEN :p_2 WHEN 4 THEN :p_3 WHEN 5 THEN :p_4 WHEN 6 THEN :p_5 WHEN 7 THEN :p_6 WHEN 8 THEN :p_7 WHEN 9 THEN :p_8 WHEN 10 THEN :p_9 END WHERE (\"ID\" IN (1,2,3,4,5,6,7,8,9,10))", sql);
|
||||||
|
|
||||||
|
sql = update.SetSource(items).Set(a => a.CreateTime, new DateTime(2020, 1, 1)).ToSql().Replace("\r\n", "");
|
||||||
|
Assert.Equal("UPDATE \"TB_TOPIC\" SET \"CREATETIME\" = :p_0 WHERE (\"ID\" IN (1,2,3,4,5,6,7,8,9,10))", sql);
|
||||||
|
|
||||||
|
sql = g.oracle.Update<ts_source_mpk>().SetSource(new[] {
|
||||||
|
new ts_source_mpk { id1 = 1, id2 = 7, xx = "a1" },
|
||||||
|
new ts_source_mpk { id1 = 1, id2 = 8, xx = "b122" }
|
||||||
|
}).NoneParameter().ToSql().Replace("\r\n", "");
|
||||||
|
|
||||||
|
var uuids = new[]
|
||||||
|
{
|
||||||
|
new tssi01{tint = 1, title = "title01"},
|
||||||
|
new tssi01{tint = 2, title = "title02"},
|
||||||
|
new tssi01{tint = 3, title = "title03"},
|
||||||
|
};
|
||||||
|
g.oracle.Insert(uuids).ExecuteAffrows();
|
||||||
|
g.oracle.Update<tssi01>().SetSource(uuids).ExecuteAffrows();
|
||||||
|
|
||||||
|
var tssi01tb = g.oracle.DbFirst.GetTableByName("tssi01");
|
||||||
|
}
|
||||||
|
public class ts_source_mpk
|
||||||
|
{
|
||||||
|
[Column(IsPrimary = true)]
|
||||||
|
public int id1 { get; set; }
|
||||||
|
[Column(IsPrimary = true)]
|
||||||
|
public int id2 { get; set; }
|
||||||
|
public string xx { get; set; }
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void SetSourceIgnore()
|
||||||
|
{
|
||||||
|
Assert.Equal("UPDATE \"TSSI01\" SET \"TINT\" = 10 WHERE (\"ID\" = '00000000-0000-0000-0000-000000000000')",
|
||||||
|
g.oracle.Update<tssi01>().NoneParameter()
|
||||||
|
.SetSourceIgnore(new tssi01 { id = Guid.Empty, tint = 10 }, col => col == null).ToSql().Replace("\r\n", ""));
|
||||||
|
}
|
||||||
|
public class tssi01
|
||||||
|
{
|
||||||
|
[Column(CanUpdate = false, DbType = "nvarchar2(36)")]
|
||||||
|
public Guid id { get; set; }
|
||||||
|
public int tint { get; set; }
|
||||||
|
public string title { get; set; }
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void IgnoreColumns()
|
||||||
|
{
|
||||||
|
var sql = update.SetSource(new Topic { Id = 1, Title = "newtitle" }).IgnoreColumns(a => new { a.Clicks, a.CreateTime }).ToSql().Replace("\r\n", "");
|
||||||
|
Assert.Equal("UPDATE \"TB_TOPIC\" SET \"TITLE\" = :p_0 WHERE (\"ID\" = 1)", sql);
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void UpdateColumns()
|
||||||
|
{
|
||||||
|
var sql = update.SetSource(new Topic { Id = 1, Title = "newtitle" }).UpdateColumns(a => a.Title).ToSql().Replace("\r\n", "");
|
||||||
|
Assert.Equal("UPDATE \"TB_TOPIC\" SET \"TITLE\" = :p_0 WHERE (\"ID\" = 1)", sql);
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Set()
|
||||||
|
{
|
||||||
|
var sql = update.Where(a => a.Id == 1).Set(a => a.Title, "newtitle").ToSql().Replace("\r\n", "");
|
||||||
|
Assert.Equal("UPDATE \"TB_TOPIC\" SET \"TITLE\" = :p_0 WHERE (\"ID\" = 1)", sql);
|
||||||
|
|
||||||
|
sql = update.Where(a => a.Id == 1).Set(a => a.Title, "newtitle").Set(a => a.CreateTime, new DateTime(2020, 1, 1)).ToSql().Replace("\r\n", "");
|
||||||
|
Assert.Equal("UPDATE \"TB_TOPIC\" SET \"TITLE\" = :p_0, \"CREATETIME\" = :p_1 WHERE (\"ID\" = 1)", sql);
|
||||||
|
|
||||||
|
sql = update.Set(a => a.Clicks * 10 / 1).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||||
|
Assert.Equal("UPDATE \"TB_TOPIC\" SET \"CLICKS\" = trunc(nvl(\"CLICKS\", 0) * 10 / 1) WHERE (\"ID\" = 1)", sql);
|
||||||
|
|
||||||
|
sql = update.Set(a => a.Id - 10).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||||
|
Assert.Equal("UPDATE \"TB_TOPIC\" SET \"ID\" = (\"ID\" - 10) WHERE (\"ID\" = 1)", sql);
|
||||||
|
|
||||||
|
int incrv = 10;
|
||||||
|
sql = update.Set(a => a.Clicks * incrv / 1).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||||
|
Assert.Equal("UPDATE \"TB_TOPIC\" SET \"CLICKS\" = trunc(nvl(\"CLICKS\", 0) * 10 / 1) WHERE (\"ID\" = 1)", sql);
|
||||||
|
|
||||||
|
sql = update.Set(a => a.Id - incrv).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||||
|
Assert.Equal("UPDATE \"TB_TOPIC\" SET \"ID\" = (\"ID\" - 10) WHERE (\"ID\" = 1)", sql);
|
||||||
|
|
||||||
|
sql = update.Set(a => a.Clicks == a.Clicks * 10 / 1).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||||
|
Assert.Equal("UPDATE \"TB_TOPIC\" SET \"CLICKS\" = trunc(\"CLICKS\" * 10 / 1) WHERE (\"ID\" = 1)", sql);
|
||||||
|
|
||||||
|
var dt2000 = DateTime.Parse("2000-01-01");
|
||||||
|
sql = update.Set(a => a.Clicks == (a.CreateTime > dt2000 ? 1 : 2)).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||||
|
Assert.Equal("UPDATE \"TB_TOPIC\" SET \"CLICKS\" = case when \"CREATETIME\" > to_timestamp('2000-01-01 00:00:00.000000','YYYY-MM-DD HH24:MI:SS.FF6') then 1 else 2 end WHERE (\"ID\" = 1)", sql);
|
||||||
|
|
||||||
|
sql = update.Set(a => a.Id == 10).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||||
|
Assert.Equal("UPDATE \"TB_TOPIC\" SET \"ID\" = 10 WHERE (\"ID\" = 1)", sql);
|
||||||
|
|
||||||
|
sql = update.Set(a => a.Clicks == null).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||||
|
Assert.Equal("UPDATE \"TB_TOPIC\" SET \"CLICKS\" = NULL WHERE (\"ID\" = 1)", sql);
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void SetRaw()
|
||||||
|
{
|
||||||
|
var sql = update.Where(a => a.Id == 1).SetRaw("clicks = clicks + :incrClick", new { incrClick = 1 }).ToSql().Replace("\r\n", "");
|
||||||
|
Assert.Equal("UPDATE \"TB_TOPIC\" SET clicks = clicks + :incrClick WHERE (\"ID\" = 1)", sql);
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void SetDto()
|
||||||
|
{
|
||||||
|
var sql = update.SetDto(new { clicks = 1, title = "xxx" }).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||||
|
Assert.Equal("UPDATE \"TB_TOPIC\" SET \"CLICKS\" = :p_0, \"TITLE\" = :p_1 WHERE (\"ID\" = 1)", sql);
|
||||||
|
sql = update.NoneParameter().SetDto(new { clicks = 1, title = "xxx" }).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||||
|
Assert.Equal("UPDATE \"TB_TOPIC\" SET \"CLICKS\" = 1, \"TITLE\" = 'xxx' WHERE (\"ID\" = 1)", sql);
|
||||||
|
|
||||||
|
sql = update.SetDto(new Dictionary<string, object> { ["clicks"] = 1, ["title"] = "xxx" }).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||||
|
Assert.Equal("UPDATE \"TB_TOPIC\" SET \"CLICKS\" = :p_0, \"TITLE\" = :p_1 WHERE (\"ID\" = 1)", sql);
|
||||||
|
sql = update.NoneParameter().SetDto(new Dictionary<string, object> { ["clicks"] = 1, ["title"] = "xxx" }).Where(a => a.Id == 1).ToSql().Replace("\r\n", "");
|
||||||
|
Assert.Equal("UPDATE \"TB_TOPIC\" SET \"CLICKS\" = 1, \"TITLE\" = 'xxx' WHERE (\"ID\" = 1)", sql);
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Where()
|
||||||
|
{
|
||||||
|
var sql = update.Where(a => a.Id == 1).SetRaw("title='newtitle'").ToSql().Replace("\r\n", "");
|
||||||
|
Assert.Equal("UPDATE \"TB_TOPIC\" SET title='newtitle' WHERE (\"ID\" = 1)", sql);
|
||||||
|
|
||||||
|
sql = update.Where("id = :id", new { id = 1 }).SetRaw("title='newtitle'").ToSql().Replace("\r\n", "");
|
||||||
|
Assert.Equal("UPDATE \"TB_TOPIC\" SET title='newtitle' WHERE (id = :id)", sql);
|
||||||
|
|
||||||
|
var item = new Topic { Id = 1, Title = "newtitle" };
|
||||||
|
sql = update.Where(item).SetRaw("title='newtitle'").ToSql().Replace("\r\n", "");
|
||||||
|
Assert.Equal("UPDATE \"TB_TOPIC\" SET title='newtitle' WHERE (\"ID\" = 1)", sql);
|
||||||
|
|
||||||
|
var items = new List<Topic>();
|
||||||
|
for (var a = 0; a < 10; a++) items.Add(new Topic { Id = a + 1, Title = $"newtitle{a}", Clicks = a * 100 });
|
||||||
|
sql = update.Where(items).SetRaw("title='newtitle'").ToSql().Replace("\r\n", "");
|
||||||
|
Assert.Equal("UPDATE \"TB_TOPIC\" SET title='newtitle' WHERE (\"ID\" IN (1,2,3,4,5,6,7,8,9,10))", sql);
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void ExecuteAffrows()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void ExecuteUpdated()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void AsTable()
|
||||||
|
{
|
||||||
|
Assert.Null(g.oracle.Update<Topic>().ToSql());
|
||||||
|
Assert.Equal("UPDATE \"TB_TOPICASTABLE\" SET title='test' \r\nWHERE (\"ID\" IN (1,2))", g.oracle.Update<Topic>(new[] { 1, 2 }).SetRaw("title='test'").AsTable(a => "tb_topicAsTable").ToSql());
|
||||||
|
Assert.Equal("UPDATE \"TB_TOPICASTABLE\" SET title='test1' \r\nWHERE (\"ID\" = 1)", g.oracle.Update<Topic>(new Topic { Id = 1, Title = "test" }).SetRaw("title='test1'").AsTable(a => "tb_topicAsTable").ToSql());
|
||||||
|
Assert.Equal("UPDATE \"TB_TOPICASTABLE\" SET title='test1' \r\nWHERE (\"ID\" IN (1,2))", g.oracle.Update<Topic>(new[] { new Topic { Id = 1, Title = "test" }, new Topic { Id = 2, Title = "test" } }).SetRaw("title='test1'").AsTable(a => "tb_topicAsTable").ToSql());
|
||||||
|
Assert.Equal("UPDATE \"TB_TOPICASTABLE\" SET title='test1' \r\nWHERE (\"ID\" = 1)", g.oracle.Update<Topic>(new { id = 1 }).SetRaw("title='test1'").AsTable(a => "tb_topicAsTable").ToSql());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,54 @@
|
|||||||
|
using FreeSql.DataAnnotations;
|
||||||
|
using System;
|
||||||
|
using System.Numerics;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace FreeSql.Tests.OracleOledbMapType
|
||||||
|
{
|
||||||
|
public class DateTimeOffSetTest
|
||||||
|
{
|
||||||
|
class Dtos_dt
|
||||||
|
{
|
||||||
|
public Guid id { get; set; }
|
||||||
|
|
||||||
|
[Column(MapType = typeof(DateTime))]
|
||||||
|
public DateTimeOffset dtos_to_dt { get; set; }
|
||||||
|
[Column(MapType = typeof(DateTime))]
|
||||||
|
public DateTimeOffset? dtofnil_to_dt { get; set; }
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void DateTimeToDateTimeOffSet()
|
||||||
|
{
|
||||||
|
//insert
|
||||||
|
var orm = g.oracle;
|
||||||
|
var item = new Dtos_dt { dtos_to_dt = DateTimeOffset.Now, dtofnil_to_dt = DateTimeOffset.Now };
|
||||||
|
Assert.Equal(1, orm.Insert<Dtos_dt>().AppendData(item).ExecuteAffrows());
|
||||||
|
var find = orm.Select<Dtos_dt>().Where(a => a.id == item.id).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.dtos_to_dt.ToString("g"), find.dtos_to_dt.ToString("g"));
|
||||||
|
Assert.Equal(item.dtofnil_to_dt.Value.ToString("g"), find.dtofnil_to_dt.Value.ToString("g"));
|
||||||
|
|
||||||
|
//update all
|
||||||
|
item.dtos_to_dt = DateTimeOffset.Now;
|
||||||
|
Assert.Equal(1, orm.Update<Dtos_dt>().SetSource(item).ExecuteAffrows());
|
||||||
|
find = orm.Select<Dtos_dt>().Where(a => a.id == item.id).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.dtos_to_dt.ToString("g"), find.dtos_to_dt.ToString("g"));
|
||||||
|
Assert.Equal(item.dtofnil_to_dt.Value.ToString("g"), find.dtofnil_to_dt.Value.ToString("g"));
|
||||||
|
|
||||||
|
//update set
|
||||||
|
Assert.Equal(1, orm.Update<Dtos_dt>().Where(a => a.id == item.id).Set(a => a.dtos_to_dt, item.dtos_to_dt = DateTimeOffset.Now).ExecuteAffrows());
|
||||||
|
find = orm.Select<Dtos_dt>().Where(a => a.id == item.id).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.dtos_to_dt.ToString("g"), find.dtos_to_dt.ToString("g"));
|
||||||
|
Assert.Equal(item.dtofnil_to_dt.Value.ToString("g"), find.dtofnil_to_dt.Value.ToString("g"));
|
||||||
|
|
||||||
|
//delete
|
||||||
|
Assert.Equal(1, orm.Delete<Dtos_dt>().Where(a => a.id == item.id).ExecuteAffrows());
|
||||||
|
Assert.Null(orm.Select<Dtos_dt>().Where(a => a.id == item.id).First());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,261 @@
|
|||||||
|
using FreeSql.DataAnnotations;
|
||||||
|
using System;
|
||||||
|
using System.Numerics;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace FreeSql.Tests.OracleOledbMapType
|
||||||
|
{
|
||||||
|
public class EnumTest
|
||||||
|
{
|
||||||
|
class EnumTestMap
|
||||||
|
{
|
||||||
|
public Guid id { get; set; }
|
||||||
|
|
||||||
|
[Column(MapType = typeof(string))]
|
||||||
|
public ToStringMapEnum enum_to_string { get; set; }
|
||||||
|
[Column(MapType = typeof(string))]
|
||||||
|
public ToStringMapEnum? enumnullable_to_string { get; set; }
|
||||||
|
|
||||||
|
[Column(MapType = typeof(int))]
|
||||||
|
public ToStringMapEnum enum_to_int { get; set; }
|
||||||
|
[Column(MapType = typeof(int?))]
|
||||||
|
public ToStringMapEnum? enumnullable_to_int { get; set; }
|
||||||
|
}
|
||||||
|
public enum ToStringMapEnum { 中国人, abc, 香港 }
|
||||||
|
[Fact]
|
||||||
|
public void EnumToString()
|
||||||
|
{
|
||||||
|
//insert
|
||||||
|
var orm = g.oracle;
|
||||||
|
var item = new EnumTestMap { };
|
||||||
|
Assert.Equal(1, orm.Insert<EnumTestMap>().AppendData(item).ExecuteAffrows());
|
||||||
|
var find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enum_to_string == ToStringMapEnum.中国人).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.enum_to_string, find.enum_to_string);
|
||||||
|
Assert.Equal(ToStringMapEnum.中国人, find.enum_to_string);
|
||||||
|
|
||||||
|
item = new EnumTestMap { enum_to_string = ToStringMapEnum.abc };
|
||||||
|
Assert.Equal(1, orm.Insert<EnumTestMap>().AppendData(item).ExecuteAffrows());
|
||||||
|
find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enum_to_string == ToStringMapEnum.abc).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.enum_to_string, find.enum_to_string);
|
||||||
|
Assert.Equal(ToStringMapEnum.abc, find.enum_to_string);
|
||||||
|
|
||||||
|
//update all
|
||||||
|
item.enum_to_string = ToStringMapEnum.香港;
|
||||||
|
Assert.Equal(1, orm.Update<EnumTestMap>().SetSource(item).ExecuteAffrows());
|
||||||
|
find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enum_to_string == ToStringMapEnum.香港).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.enum_to_string, find.enum_to_string);
|
||||||
|
Assert.Equal(ToStringMapEnum.香港, find.enum_to_string);
|
||||||
|
|
||||||
|
item.enum_to_string = ToStringMapEnum.中国人;
|
||||||
|
Assert.Equal(1, orm.Update<EnumTestMap>().SetSource(item).ExecuteAffrows());
|
||||||
|
find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enum_to_string == ToStringMapEnum.中国人).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.enum_to_string, find.enum_to_string);
|
||||||
|
Assert.Equal(ToStringMapEnum.中国人, find.enum_to_string);
|
||||||
|
|
||||||
|
//update set
|
||||||
|
Assert.Equal(1, orm.Update<EnumTestMap>().Where(a => a.id == item.id).Set(a => a.enum_to_string, ToStringMapEnum.香港).ExecuteAffrows());
|
||||||
|
find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enum_to_string == ToStringMapEnum.香港).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(ToStringMapEnum.香港, find.enum_to_string);
|
||||||
|
|
||||||
|
Assert.Equal(1, orm.Update<EnumTestMap>().Where(a => a.id == item.id).Set(a => a.enum_to_string, ToStringMapEnum.abc).ExecuteAffrows());
|
||||||
|
find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enum_to_string == ToStringMapEnum.abc).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(ToStringMapEnum.abc, find.enum_to_string);
|
||||||
|
|
||||||
|
//delete
|
||||||
|
Assert.Equal(0, orm.Delete<EnumTestMap>().Where(a => a.id == item.id && a.enum_to_string == ToStringMapEnum.中国人).ExecuteAffrows());
|
||||||
|
Assert.Equal(0, orm.Delete<EnumTestMap>().Where(a => a.id == item.id && a.enum_to_string == ToStringMapEnum.香港).ExecuteAffrows());
|
||||||
|
Assert.Equal(1, orm.Delete<EnumTestMap>().Where(a => a.id == item.id && a.enum_to_string == ToStringMapEnum.abc).ExecuteAffrows());
|
||||||
|
Assert.Null(orm.Select<EnumTestMap>().Where(a => a.id == item.id).First());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void EnumNullableToString()
|
||||||
|
{
|
||||||
|
//insert
|
||||||
|
var orm = g.oracle;
|
||||||
|
var item = new EnumTestMap { };
|
||||||
|
Assert.Equal(1, orm.Insert<EnumTestMap>().AppendData(item).ExecuteAffrows());
|
||||||
|
var find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_string == null).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.enumnullable_to_string, find.enumnullable_to_string);
|
||||||
|
Assert.Null(find.enumnullable_to_string);
|
||||||
|
|
||||||
|
item = new EnumTestMap { enumnullable_to_string = ToStringMapEnum.中国人 };
|
||||||
|
Assert.Equal(1, orm.Insert<EnumTestMap>().AppendData(item).ExecuteAffrows());
|
||||||
|
find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.中国人).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.enumnullable_to_string, find.enumnullable_to_string);
|
||||||
|
Assert.Equal(ToStringMapEnum.中国人, find.enumnullable_to_string);
|
||||||
|
|
||||||
|
//update all
|
||||||
|
item.enumnullable_to_string = ToStringMapEnum.香港;
|
||||||
|
Assert.Equal(1, orm.Update<EnumTestMap>().SetSource(item).ExecuteAffrows());
|
||||||
|
find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.香港).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.enumnullable_to_string, find.enumnullable_to_string);
|
||||||
|
Assert.Equal(ToStringMapEnum.香港, find.enumnullable_to_string);
|
||||||
|
|
||||||
|
item.enumnullable_to_string = null;
|
||||||
|
Assert.Equal(1, orm.Update<EnumTestMap>().SetSource(item).ExecuteAffrows());
|
||||||
|
Assert.Null(orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.香港).First());
|
||||||
|
find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_string == null).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.enumnullable_to_string, find.enumnullable_to_string);
|
||||||
|
Assert.Null(find.enumnullable_to_string);
|
||||||
|
|
||||||
|
//update set
|
||||||
|
Assert.Equal(1, orm.Update<EnumTestMap>().Where(a => a.id == item.id).Set(a => a.enumnullable_to_string, ToStringMapEnum.abc).ExecuteAffrows());
|
||||||
|
find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.abc).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(ToStringMapEnum.abc, find.enumnullable_to_string);
|
||||||
|
|
||||||
|
|
||||||
|
Assert.Equal(1, orm.Update<EnumTestMap>().Where(a => a.id == item.id).Set(a => a.enumnullable_to_string, null).ExecuteAffrows());
|
||||||
|
Assert.Null(orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.abc).First());
|
||||||
|
find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_string == null).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Null(find.enumnullable_to_string);
|
||||||
|
|
||||||
|
//delete
|
||||||
|
Assert.Equal(0, orm.Delete<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.中国人).ExecuteAffrows());
|
||||||
|
Assert.Equal(0, orm.Delete<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.香港).ExecuteAffrows());
|
||||||
|
Assert.Equal(1, orm.Delete<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_string == null).ExecuteAffrows());
|
||||||
|
Assert.Null(orm.Select<EnumTestMap>().Where(a => a.id == item.id).First());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void EnumToInt()
|
||||||
|
{
|
||||||
|
//insert
|
||||||
|
var orm = g.oracle;
|
||||||
|
var item = new EnumTestMap { };
|
||||||
|
Assert.Equal(1, orm.Insert<EnumTestMap>().AppendData(item).ExecuteAffrows());
|
||||||
|
var find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enum_to_int == ToStringMapEnum.中国人).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.enum_to_int, find.enum_to_int);
|
||||||
|
Assert.Equal(ToStringMapEnum.中国人, find.enum_to_int);
|
||||||
|
|
||||||
|
item = new EnumTestMap { enum_to_int = ToStringMapEnum.abc };
|
||||||
|
Assert.Equal(1, orm.Insert<EnumTestMap>().AppendData(item).ExecuteAffrows());
|
||||||
|
find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enum_to_int == ToStringMapEnum.abc).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.enum_to_int, find.enum_to_int);
|
||||||
|
Assert.Equal(ToStringMapEnum.abc, find.enum_to_int);
|
||||||
|
|
||||||
|
//update all
|
||||||
|
item.enum_to_int = ToStringMapEnum.香港;
|
||||||
|
Assert.Equal(1, orm.Update<EnumTestMap>().SetSource(item).ExecuteAffrows());
|
||||||
|
find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enum_to_int == ToStringMapEnum.香港).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.enum_to_int, find.enum_to_int);
|
||||||
|
Assert.Equal(ToStringMapEnum.香港, find.enum_to_int);
|
||||||
|
|
||||||
|
item.enum_to_int = ToStringMapEnum.中国人;
|
||||||
|
Assert.Equal(1, orm.Update<EnumTestMap>().SetSource(item).ExecuteAffrows());
|
||||||
|
find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enum_to_int == ToStringMapEnum.中国人).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.enum_to_int, find.enum_to_int);
|
||||||
|
Assert.Equal(ToStringMapEnum.中国人, find.enum_to_int);
|
||||||
|
|
||||||
|
//update set
|
||||||
|
Assert.Equal(1, orm.Update<EnumTestMap>().Where(a => a.id == item.id).Set(a => a.enum_to_int, ToStringMapEnum.香港).ExecuteAffrows());
|
||||||
|
find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enum_to_int == ToStringMapEnum.香港).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(ToStringMapEnum.香港, find.enum_to_int);
|
||||||
|
|
||||||
|
Assert.Equal(1, orm.Update<EnumTestMap>().Where(a => a.id == item.id).Set(a => a.enum_to_int, ToStringMapEnum.abc).ExecuteAffrows());
|
||||||
|
find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enum_to_int == ToStringMapEnum.abc).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(ToStringMapEnum.abc, find.enum_to_int);
|
||||||
|
|
||||||
|
//delete
|
||||||
|
Assert.Equal(0, orm.Delete<EnumTestMap>().Where(a => a.id == item.id && a.enum_to_int == ToStringMapEnum.中国人).ExecuteAffrows());
|
||||||
|
Assert.Equal(0, orm.Delete<EnumTestMap>().Where(a => a.id == item.id && a.enum_to_int == ToStringMapEnum.香港).ExecuteAffrows());
|
||||||
|
Assert.Equal(1, orm.Delete<EnumTestMap>().Where(a => a.id == item.id && a.enum_to_int == ToStringMapEnum.abc).ExecuteAffrows());
|
||||||
|
Assert.Null(orm.Select<EnumTestMap>().Where(a => a.id == item.id).First());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void EnumNullableToInt()
|
||||||
|
{
|
||||||
|
//insert
|
||||||
|
var orm = g.oracle;
|
||||||
|
var item = new EnumTestMap { };
|
||||||
|
Assert.Equal(1, orm.Insert<EnumTestMap>().AppendData(item).ExecuteAffrows());
|
||||||
|
var find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_int == null).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.enumnullable_to_int, find.enumnullable_to_int);
|
||||||
|
Assert.Null(find.enumnullable_to_int);
|
||||||
|
|
||||||
|
item = new EnumTestMap { enumnullable_to_int = ToStringMapEnum.中国人 };
|
||||||
|
Assert.Equal(1, orm.Insert<EnumTestMap>().AppendData(item).ExecuteAffrows());
|
||||||
|
find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_int == ToStringMapEnum.中国人).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.enumnullable_to_int, find.enumnullable_to_int);
|
||||||
|
Assert.Equal(ToStringMapEnum.中国人, find.enumnullable_to_int);
|
||||||
|
|
||||||
|
//update all
|
||||||
|
item.enumnullable_to_int = ToStringMapEnum.香港;
|
||||||
|
Assert.Equal(1, orm.Update<EnumTestMap>().SetSource(item).ExecuteAffrows());
|
||||||
|
find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_int == ToStringMapEnum.香港).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.enumnullable_to_int, find.enumnullable_to_int);
|
||||||
|
Assert.Equal(ToStringMapEnum.香港, find.enumnullable_to_int);
|
||||||
|
|
||||||
|
item.enumnullable_to_int = null;
|
||||||
|
Assert.Equal(1, orm.Update<EnumTestMap>().SetSource(item).ExecuteAffrows());
|
||||||
|
Assert.Null(orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_int == ToStringMapEnum.香港).First());
|
||||||
|
find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_int == null).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.enumnullable_to_int, find.enumnullable_to_int);
|
||||||
|
Assert.Null(find.enumnullable_to_int);
|
||||||
|
|
||||||
|
//update set
|
||||||
|
Assert.Equal(1, orm.Update<EnumTestMap>().Where(a => a.id == item.id).Set(a => a.enumnullable_to_int, ToStringMapEnum.abc).ExecuteAffrows());
|
||||||
|
find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_int == ToStringMapEnum.abc).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(ToStringMapEnum.abc, find.enumnullable_to_int);
|
||||||
|
|
||||||
|
|
||||||
|
Assert.Equal(1, orm.Update<EnumTestMap>().Where(a => a.id == item.id).Set(a => a.enumnullable_to_int, null).ExecuteAffrows());
|
||||||
|
Assert.Null(orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_int == ToStringMapEnum.abc).First());
|
||||||
|
find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_int == null).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Null(find.enumnullable_to_int);
|
||||||
|
|
||||||
|
//delete
|
||||||
|
Assert.Equal(0, orm.Delete<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_int == ToStringMapEnum.中国人).ExecuteAffrows());
|
||||||
|
Assert.Equal(0, orm.Delete<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_int == ToStringMapEnum.香港).ExecuteAffrows());
|
||||||
|
Assert.Equal(1, orm.Delete<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_int == null).ExecuteAffrows());
|
||||||
|
Assert.Null(orm.Select<EnumTestMap>().Where(a => a.id == item.id).First());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,570 @@
|
|||||||
|
using FreeSql.DataAnnotations;
|
||||||
|
using System;
|
||||||
|
using System.Numerics;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace FreeSql.Tests.OracleOledbMapType
|
||||||
|
{
|
||||||
|
public class ToStringTest
|
||||||
|
{
|
||||||
|
class ToStringMap
|
||||||
|
{
|
||||||
|
public Guid id { get; set; }
|
||||||
|
|
||||||
|
[Column(MapType = typeof(string))]
|
||||||
|
public TimeSpan timespan_to_string { get; set; }
|
||||||
|
[Column(MapType = typeof(string))]
|
||||||
|
public TimeSpan? timespannullable_to_string { get; set; }
|
||||||
|
|
||||||
|
[Column(MapType = typeof(string))]
|
||||||
|
public DateTime datetime_to_string { get; set; }
|
||||||
|
[Column(MapType = typeof(string))]
|
||||||
|
public DateTime? datetimenullable_to_string { get; set; }
|
||||||
|
|
||||||
|
[Column(MapType = typeof(string))]
|
||||||
|
public Guid guid_to_string { get; set; }
|
||||||
|
[Column(MapType = typeof(string))]
|
||||||
|
public Guid? guidnullable_to_string { get; set; }
|
||||||
|
|
||||||
|
[Column(MapType = typeof(string))]
|
||||||
|
public ToStringMapEnum enum_to_string { get; set; }
|
||||||
|
[Column(MapType = typeof(string))]
|
||||||
|
public ToStringMapEnum? enumnullable_to_string { get; set; }
|
||||||
|
|
||||||
|
[Column(MapType = typeof(string))]
|
||||||
|
public BigInteger biginteger_to_string { get; set; }
|
||||||
|
[Column(MapType = typeof(string))]
|
||||||
|
public BigInteger? bigintegernullable_to_string { get; set; }
|
||||||
|
}
|
||||||
|
public enum ToStringMapEnum { 中国人, abc, 香港 }
|
||||||
|
[Fact]
|
||||||
|
public void Enum1()
|
||||||
|
{
|
||||||
|
//insert
|
||||||
|
var orm = g.oracle;
|
||||||
|
var item = new ToStringMap { };
|
||||||
|
Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows());
|
||||||
|
var find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.enum_to_string == ToStringMapEnum.中国人).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.enum_to_string, find.enum_to_string);
|
||||||
|
Assert.Equal(ToStringMapEnum.中国人, find.enum_to_string);
|
||||||
|
|
||||||
|
item = new ToStringMap { enum_to_string = ToStringMapEnum.abc };
|
||||||
|
Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.enum_to_string == ToStringMapEnum.abc).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.enum_to_string, find.enum_to_string);
|
||||||
|
Assert.Equal(ToStringMapEnum.abc, find.enum_to_string);
|
||||||
|
|
||||||
|
//update all
|
||||||
|
item.enum_to_string = ToStringMapEnum.香港;
|
||||||
|
Assert.Equal(1, orm.Update<ToStringMap>().SetSource(item).ExecuteAffrows());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.enum_to_string == ToStringMapEnum.香港).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.enum_to_string, find.enum_to_string);
|
||||||
|
Assert.Equal(ToStringMapEnum.香港, find.enum_to_string);
|
||||||
|
|
||||||
|
item.enum_to_string = ToStringMapEnum.中国人;
|
||||||
|
Assert.Equal(1, orm.Update<ToStringMap>().SetSource(item).ExecuteAffrows());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.enum_to_string == ToStringMapEnum.中国人).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.enum_to_string, find.enum_to_string);
|
||||||
|
Assert.Equal(ToStringMapEnum.中国人, find.enum_to_string);
|
||||||
|
|
||||||
|
//update set
|
||||||
|
Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.enum_to_string, ToStringMapEnum.香港).ExecuteAffrows());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.enum_to_string == ToStringMapEnum.香港).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(ToStringMapEnum.香港, find.enum_to_string);
|
||||||
|
|
||||||
|
Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.enum_to_string, ToStringMapEnum.abc).ExecuteAffrows());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.enum_to_string == ToStringMapEnum.abc).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(ToStringMapEnum.abc, find.enum_to_string);
|
||||||
|
|
||||||
|
//delete
|
||||||
|
Assert.Equal(0, orm.Delete<ToStringMap>().Where(a => a.id == item.id && a.enum_to_string == ToStringMapEnum.中国人).ExecuteAffrows());
|
||||||
|
Assert.Equal(0, orm.Delete<ToStringMap>().Where(a => a.id == item.id && a.enum_to_string == ToStringMapEnum.香港).ExecuteAffrows());
|
||||||
|
Assert.Equal(1, orm.Delete<ToStringMap>().Where(a => a.id == item.id && a.enum_to_string == ToStringMapEnum.abc).ExecuteAffrows());
|
||||||
|
Assert.Null(orm.Select<ToStringMap>().Where(a => a.id == item.id).First());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void EnumNullable()
|
||||||
|
{
|
||||||
|
//insert
|
||||||
|
var orm = g.oracle;
|
||||||
|
var item = new ToStringMap { };
|
||||||
|
Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows());
|
||||||
|
var find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.enumnullable_to_string == null).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.enumnullable_to_string, find.enumnullable_to_string);
|
||||||
|
Assert.Null(find.enumnullable_to_string);
|
||||||
|
|
||||||
|
item = new ToStringMap { enumnullable_to_string = ToStringMapEnum.中国人 };
|
||||||
|
Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.中国人).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.enumnullable_to_string, find.enumnullable_to_string);
|
||||||
|
Assert.Equal(ToStringMapEnum.中国人, find.enumnullable_to_string);
|
||||||
|
|
||||||
|
//update all
|
||||||
|
item.enumnullable_to_string = ToStringMapEnum.香港;
|
||||||
|
Assert.Equal(1, orm.Update<ToStringMap>().SetSource(item).ExecuteAffrows());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.香港).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.enumnullable_to_string, find.enumnullable_to_string);
|
||||||
|
Assert.Equal(ToStringMapEnum.香港, find.enumnullable_to_string);
|
||||||
|
|
||||||
|
item.enumnullable_to_string = null;
|
||||||
|
Assert.Equal(1, orm.Update<ToStringMap>().SetSource(item).ExecuteAffrows());
|
||||||
|
Assert.Null(orm.Select<ToStringMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.香港).First());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.enumnullable_to_string == null).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.enumnullable_to_string, find.enumnullable_to_string);
|
||||||
|
Assert.Null(find.enumnullable_to_string);
|
||||||
|
|
||||||
|
//update set
|
||||||
|
Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.enumnullable_to_string, ToStringMapEnum.abc).ExecuteAffrows());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.abc).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(ToStringMapEnum.abc, find.enumnullable_to_string);
|
||||||
|
|
||||||
|
|
||||||
|
Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.enumnullable_to_string, null).ExecuteAffrows());
|
||||||
|
Assert.Null(orm.Select<ToStringMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.abc).First());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.enumnullable_to_string == null).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Null(find.enumnullable_to_string);
|
||||||
|
|
||||||
|
//delete
|
||||||
|
Assert.Equal(0, orm.Delete<ToStringMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.中国人).ExecuteAffrows());
|
||||||
|
Assert.Equal(0, orm.Delete<ToStringMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.香港).ExecuteAffrows());
|
||||||
|
Assert.Equal(1, orm.Delete<ToStringMap>().Where(a => a.id == item.id && a.enumnullable_to_string == null).ExecuteAffrows());
|
||||||
|
Assert.Null(orm.Select<ToStringMap>().Where(a => a.id == item.id).First());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void BigInteger1()
|
||||||
|
{
|
||||||
|
//insert
|
||||||
|
var orm = g.oracle;
|
||||||
|
var item = new ToStringMap { };
|
||||||
|
Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows());
|
||||||
|
var find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.biginteger_to_string == 0).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.biginteger_to_string, find.biginteger_to_string);
|
||||||
|
Assert.Equal(0, find.biginteger_to_string);
|
||||||
|
|
||||||
|
item = new ToStringMap { biginteger_to_string = 100 };
|
||||||
|
Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.biginteger_to_string == 100).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.biginteger_to_string, find.biginteger_to_string);
|
||||||
|
Assert.Equal(100, find.biginteger_to_string);
|
||||||
|
|
||||||
|
//update all
|
||||||
|
item.biginteger_to_string = 200;
|
||||||
|
Assert.Equal(1, orm.Update<ToStringMap>().SetSource(item).ExecuteAffrows());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.biginteger_to_string == 200).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.biginteger_to_string, find.biginteger_to_string);
|
||||||
|
Assert.Equal(200, find.biginteger_to_string);
|
||||||
|
|
||||||
|
item.biginteger_to_string = 205;
|
||||||
|
Assert.Equal(1, orm.Update<ToStringMap>().SetSource(item).ExecuteAffrows());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.biginteger_to_string == 205).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.biginteger_to_string, find.biginteger_to_string);
|
||||||
|
Assert.Equal(205, find.biginteger_to_string);
|
||||||
|
|
||||||
|
//update set
|
||||||
|
Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.biginteger_to_string, 522).ExecuteAffrows());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.biginteger_to_string == 522).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(522, find.biginteger_to_string);
|
||||||
|
|
||||||
|
Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.biginteger_to_string, 10005).ExecuteAffrows());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.biginteger_to_string == 10005).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(10005, find.biginteger_to_string);
|
||||||
|
|
||||||
|
//delete
|
||||||
|
Assert.Equal(0, orm.Delete<ToStringMap>().Where(a => a.id == item.id && a.biginteger_to_string == 522).ExecuteAffrows());
|
||||||
|
Assert.Equal(0, orm.Delete<ToStringMap>().Where(a => a.id == item.id && a.biginteger_to_string == 205).ExecuteAffrows());
|
||||||
|
Assert.Equal(1, orm.Delete<ToStringMap>().Where(a => a.id == item.id && a.biginteger_to_string == 10005).ExecuteAffrows());
|
||||||
|
Assert.Null(orm.Select<ToStringMap>().Where(a => a.id == item.id).First());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void BigIntegerNullable()
|
||||||
|
{
|
||||||
|
//insert
|
||||||
|
var orm = g.oracle;
|
||||||
|
var item = new ToStringMap { };
|
||||||
|
Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows());
|
||||||
|
var find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.bigintegernullable_to_string == null).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.bigintegernullable_to_string, find.bigintegernullable_to_string);
|
||||||
|
Assert.Null(find.bigintegernullable_to_string);
|
||||||
|
|
||||||
|
item = new ToStringMap { bigintegernullable_to_string = 101 };
|
||||||
|
Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.bigintegernullable_to_string == 101).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.bigintegernullable_to_string, find.bigintegernullable_to_string);
|
||||||
|
Assert.Equal(101, find.bigintegernullable_to_string);
|
||||||
|
|
||||||
|
//update all
|
||||||
|
item.bigintegernullable_to_string = 2004;
|
||||||
|
Assert.Equal(1, orm.Update<ToStringMap>().SetSource(item).ExecuteAffrows());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.bigintegernullable_to_string == 2004).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.bigintegernullable_to_string, find.bigintegernullable_to_string);
|
||||||
|
Assert.Equal(2004, find.bigintegernullable_to_string);
|
||||||
|
|
||||||
|
item.bigintegernullable_to_string = null;
|
||||||
|
Assert.Equal(1, orm.Update<ToStringMap>().SetSource(item).ExecuteAffrows());
|
||||||
|
Assert.Null(orm.Select<ToStringMap>().Where(a => a.id == item.id && a.bigintegernullable_to_string == 2004).First());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.bigintegernullable_to_string == null).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.bigintegernullable_to_string, find.bigintegernullable_to_string);
|
||||||
|
Assert.Null(find.bigintegernullable_to_string);
|
||||||
|
|
||||||
|
//update set
|
||||||
|
Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.bigintegernullable_to_string, 998).ExecuteAffrows());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.bigintegernullable_to_string == 998).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(998, find.bigintegernullable_to_string);
|
||||||
|
|
||||||
|
|
||||||
|
Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.bigintegernullable_to_string, null).ExecuteAffrows());
|
||||||
|
Assert.Null(orm.Select<ToStringMap>().Where(a => a.id == item.id && a.bigintegernullable_to_string == 998).First());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.bigintegernullable_to_string == null).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Null(find.bigintegernullable_to_string);
|
||||||
|
|
||||||
|
//delete
|
||||||
|
Assert.Equal(0, orm.Delete<ToStringMap>().Where(a => a.id == item.id && a.bigintegernullable_to_string == 998).ExecuteAffrows());
|
||||||
|
Assert.Equal(0, orm.Delete<ToStringMap>().Where(a => a.id == item.id && a.bigintegernullable_to_string == 2004).ExecuteAffrows());
|
||||||
|
Assert.Equal(1, orm.Delete<ToStringMap>().Where(a => a.id == item.id && a.bigintegernullable_to_string == null).ExecuteAffrows());
|
||||||
|
Assert.Null(orm.Select<ToStringMap>().Where(a => a.id == item.id).First());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void TimeSpan1()
|
||||||
|
{
|
||||||
|
//insert
|
||||||
|
var orm = g.oracle;
|
||||||
|
var item = new ToStringMap { };
|
||||||
|
Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows());
|
||||||
|
var find = orm.Select<ToStringMap>().Where(a => a.id == item.id).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.timespan_to_string, find.timespan_to_string);
|
||||||
|
Assert.Equal(TimeSpan.Zero, find.timespan_to_string);
|
||||||
|
|
||||||
|
item = new ToStringMap { timespan_to_string = TimeSpan.FromDays(1) };
|
||||||
|
Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.timespan_to_string, find.timespan_to_string);
|
||||||
|
Assert.Equal(TimeSpan.FromDays(1), find.timespan_to_string);
|
||||||
|
|
||||||
|
//update all
|
||||||
|
item.timespan_to_string = TimeSpan.FromHours(10);
|
||||||
|
Assert.Equal(1, orm.Update<ToStringMap>().SetSource(item).ExecuteAffrows());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.timespan_to_string, find.timespan_to_string);
|
||||||
|
Assert.Equal(TimeSpan.FromHours(10), find.timespan_to_string);
|
||||||
|
|
||||||
|
//update set
|
||||||
|
Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.timespan_to_string, TimeSpan.FromHours(11)).ExecuteAffrows());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(TimeSpan.FromHours(11), find.timespan_to_string);
|
||||||
|
|
||||||
|
//delete
|
||||||
|
Assert.Equal(1, orm.Delete<ToStringMap>().Where(a => a.id == item.id).ExecuteAffrows());
|
||||||
|
Assert.Null(orm.Select<ToStringMap>().Where(a => a.id == item.id).First());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void TimeSpanNullable()
|
||||||
|
{
|
||||||
|
//insert
|
||||||
|
var orm = g.oracle;
|
||||||
|
var item = new ToStringMap { };
|
||||||
|
Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows());
|
||||||
|
var find = orm.Select<ToStringMap>().Where(a => a.id == item.id).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.timespannullable_to_string, find.timespannullable_to_string);
|
||||||
|
Assert.Null(find.timespannullable_to_string);
|
||||||
|
|
||||||
|
item = new ToStringMap { timespannullable_to_string = TimeSpan.FromDays(1) };
|
||||||
|
Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.timespannullable_to_string, find.timespannullable_to_string);
|
||||||
|
Assert.Equal(TimeSpan.FromDays(1), find.timespannullable_to_string);
|
||||||
|
|
||||||
|
//update all
|
||||||
|
item.timespannullable_to_string = TimeSpan.FromHours(10);
|
||||||
|
Assert.Equal(1, orm.Update<ToStringMap>().SetSource(item).ExecuteAffrows());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.timespannullable_to_string, find.timespannullable_to_string);
|
||||||
|
Assert.Equal(TimeSpan.FromHours(10), find.timespannullable_to_string);
|
||||||
|
|
||||||
|
item.timespannullable_to_string = null;
|
||||||
|
Assert.Equal(1, orm.Update<ToStringMap>().SetSource(item).ExecuteAffrows());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.timespannullable_to_string, find.timespannullable_to_string);
|
||||||
|
Assert.Null(find.timespannullable_to_string);
|
||||||
|
|
||||||
|
//update set
|
||||||
|
Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.timespannullable_to_string, TimeSpan.FromHours(11)).ExecuteAffrows());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(TimeSpan.FromHours(11), find.timespannullable_to_string);
|
||||||
|
|
||||||
|
Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.timespannullable_to_string, null).ExecuteAffrows());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Null(find.timespannullable_to_string);
|
||||||
|
|
||||||
|
//delete
|
||||||
|
Assert.Equal(1, orm.Delete<ToStringMap>().Where(a => a.id == item.id).ExecuteAffrows());
|
||||||
|
Assert.Null(orm.Select<ToStringMap>().Where(a => a.id == item.id).First());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void DateTime1()
|
||||||
|
{
|
||||||
|
//insert
|
||||||
|
var orm = g.oracle;
|
||||||
|
var item = new ToStringMap { };
|
||||||
|
Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows());
|
||||||
|
var find = orm.Select<ToStringMap>().Where(a => a.id == item.id).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.datetime_to_string, find.datetime_to_string);
|
||||||
|
Assert.Equal(DateTime.MinValue, find.datetime_to_string);
|
||||||
|
|
||||||
|
item = new ToStringMap { datetime_to_string = DateTime.Parse("2000-1-1") };
|
||||||
|
Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.datetime_to_string, find.datetime_to_string);
|
||||||
|
Assert.Equal(DateTime.Parse("2000-1-1"), find.datetime_to_string);
|
||||||
|
|
||||||
|
//update all
|
||||||
|
item.datetime_to_string = DateTime.Parse("2000-1-11");
|
||||||
|
Assert.Equal(1, orm.Update<ToStringMap>().SetSource(item).ExecuteAffrows());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.datetime_to_string, find.datetime_to_string);
|
||||||
|
Assert.Equal(DateTime.Parse("2000-1-11"), find.datetime_to_string);
|
||||||
|
|
||||||
|
//update set
|
||||||
|
Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.datetime_to_string, DateTime.Parse("2000-1-12")).ExecuteAffrows());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(DateTime.Parse("2000-1-12"), find.datetime_to_string);
|
||||||
|
|
||||||
|
//delete
|
||||||
|
Assert.Equal(1, orm.Delete<ToStringMap>().Where(a => a.id == item.id).ExecuteAffrows());
|
||||||
|
Assert.Null(orm.Select<ToStringMap>().Where(a => a.id == item.id).First());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void DateTimeNullable()
|
||||||
|
{
|
||||||
|
//insert
|
||||||
|
var orm = g.oracle;
|
||||||
|
var item = new ToStringMap { };
|
||||||
|
Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows());
|
||||||
|
var find = orm.Select<ToStringMap>().Where(a => a.id == item.id).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.datetimenullable_to_string, find.datetimenullable_to_string);
|
||||||
|
Assert.Null(find.datetimenullable_to_string);
|
||||||
|
|
||||||
|
item = new ToStringMap { datetimenullable_to_string = DateTime.Parse("2000-1-1") };
|
||||||
|
Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.datetimenullable_to_string, find.datetimenullable_to_string);
|
||||||
|
Assert.Equal(DateTime.Parse("2000-1-1"), find.datetimenullable_to_string);
|
||||||
|
|
||||||
|
//update all
|
||||||
|
item.datetimenullable_to_string = DateTime.Parse("2000-1-11");
|
||||||
|
Assert.Equal(1, orm.Update<ToStringMap>().SetSource(item).ExecuteAffrows());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.datetimenullable_to_string, find.datetimenullable_to_string);
|
||||||
|
Assert.Equal(DateTime.Parse("2000-1-11"), find.datetimenullable_to_string);
|
||||||
|
|
||||||
|
item.datetimenullable_to_string = null;
|
||||||
|
Assert.Equal(1, orm.Update<ToStringMap>().SetSource(item).ExecuteAffrows());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.datetimenullable_to_string, find.datetimenullable_to_string);
|
||||||
|
Assert.Null(find.datetimenullable_to_string);
|
||||||
|
|
||||||
|
//update set
|
||||||
|
Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.datetimenullable_to_string, DateTime.Parse("2000-1-12")).ExecuteAffrows());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(DateTime.Parse("2000-1-12"), find.datetimenullable_to_string);
|
||||||
|
|
||||||
|
Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.datetimenullable_to_string, null).ExecuteAffrows());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Null(find.datetimenullable_to_string);
|
||||||
|
|
||||||
|
//delete
|
||||||
|
Assert.Equal(1, orm.Delete<ToStringMap>().Where(a => a.id == item.id).ExecuteAffrows());
|
||||||
|
Assert.Null(orm.Select<ToStringMap>().Where(a => a.id == item.id).First());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Guid1()
|
||||||
|
{
|
||||||
|
//insert
|
||||||
|
var orm = g.oracle;
|
||||||
|
var item = new ToStringMap { };
|
||||||
|
Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows());
|
||||||
|
var find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.guid_to_string == Guid.Empty).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.guid_to_string, find.guid_to_string);
|
||||||
|
Assert.Equal(Guid.Empty, find.guid_to_string);
|
||||||
|
|
||||||
|
var newid = Guid.NewGuid();
|
||||||
|
item = new ToStringMap { guid_to_string = newid };
|
||||||
|
Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.guid_to_string == newid).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.guid_to_string, find.guid_to_string);
|
||||||
|
Assert.Equal(newid, find.guid_to_string);
|
||||||
|
|
||||||
|
//update all
|
||||||
|
newid = Guid.NewGuid();
|
||||||
|
item.guid_to_string = newid;
|
||||||
|
Assert.Equal(1, orm.Update<ToStringMap>().SetSource(item).ExecuteAffrows());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.guid_to_string == newid).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.guid_to_string, find.guid_to_string);
|
||||||
|
Assert.Equal(newid, find.guid_to_string);
|
||||||
|
|
||||||
|
//update set
|
||||||
|
newid = Guid.NewGuid();
|
||||||
|
Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.guid_to_string, newid).ExecuteAffrows());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.guid_to_string == newid).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(newid, find.guid_to_string);
|
||||||
|
|
||||||
|
//delete
|
||||||
|
Assert.Equal(1, orm.Delete<ToStringMap>().Where(a => a.id == item.id && a.guid_to_string == newid).ExecuteAffrows());
|
||||||
|
Assert.Null(orm.Select<ToStringMap>().Where(a => a.id == item.id).First());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void GuidNullable()
|
||||||
|
{
|
||||||
|
//insert
|
||||||
|
var orm = g.oracle;
|
||||||
|
var item = new ToStringMap { };
|
||||||
|
Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows());
|
||||||
|
var find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.guidnullable_to_string == null).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.guidnullable_to_string, find.guidnullable_to_string);
|
||||||
|
Assert.Null(find.guidnullable_to_string);
|
||||||
|
|
||||||
|
var newid = Guid.NewGuid();
|
||||||
|
item = new ToStringMap { guidnullable_to_string = newid };
|
||||||
|
Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.guidnullable_to_string == newid).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.guidnullable_to_string, find.guidnullable_to_string);
|
||||||
|
Assert.Equal(newid, find.guidnullable_to_string);
|
||||||
|
|
||||||
|
//update all
|
||||||
|
newid = Guid.NewGuid();
|
||||||
|
item.guidnullable_to_string = newid;
|
||||||
|
Assert.Equal(1, orm.Update<ToStringMap>().SetSource(item).ExecuteAffrows());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.guidnullable_to_string == newid).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.guidnullable_to_string, find.guidnullable_to_string);
|
||||||
|
Assert.Equal(newid, find.guidnullable_to_string);
|
||||||
|
|
||||||
|
item.guidnullable_to_string = null;
|
||||||
|
Assert.Equal(1, orm.Update<ToStringMap>().SetSource(item).ExecuteAffrows());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.guidnullable_to_string == null).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(item.guidnullable_to_string, find.guidnullable_to_string);
|
||||||
|
Assert.Null(find.guidnullable_to_string);
|
||||||
|
|
||||||
|
//update set
|
||||||
|
newid = Guid.NewGuid();
|
||||||
|
Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.guidnullable_to_string, newid).ExecuteAffrows());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.guidnullable_to_string == newid).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Equal(newid, find.guidnullable_to_string);
|
||||||
|
|
||||||
|
Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.guidnullable_to_string, null).ExecuteAffrows());
|
||||||
|
find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.guidnullable_to_string == null).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(item.id, find.id);
|
||||||
|
Assert.Null(find.guidnullable_to_string);
|
||||||
|
|
||||||
|
//delete
|
||||||
|
Assert.Equal(1, orm.Delete<ToStringMap>().Where(a => a.id == item.id && a.guidnullable_to_string == null).ExecuteAffrows());
|
||||||
|
Assert.Null(orm.Select<ToStringMap>().Where(a => a.id == item.id).First());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,75 @@
|
|||||||
|
using FreeSql.DataAnnotations;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace FreeSql.Tests.OracleOledb
|
||||||
|
{
|
||||||
|
public class OracleOledbAdoTest
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public void Pool()
|
||||||
|
{
|
||||||
|
var t1 = g.oracle.Ado.MasterPool.StatisticsFullily;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void SlavePools()
|
||||||
|
{
|
||||||
|
var t2 = g.oracle.Ado.SlavePools.Count;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void ExecuteTest()
|
||||||
|
{
|
||||||
|
Assert.True(g.oracle.Ado.ExecuteConnectTest());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void ExecuteReader()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void ExecuteArray()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void ExecuteNonQuery()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void ExecuteScalar()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Query()
|
||||||
|
{
|
||||||
|
|
||||||
|
var t3 = g.oracle.Ado.Query<xxx>("select * from \"TB_TOPIC\"");
|
||||||
|
|
||||||
|
var t4 = g.oracle.Ado.Query<(int, string, string)>("select * from \"TB_TOPIC\"");
|
||||||
|
|
||||||
|
var t5 = g.oracle.Ado.Query<dynamic>("select * from \"TB_TOPIC\"");
|
||||||
|
|
||||||
|
var t6 = g.oracle.Ado.Query<xxx>("select * from TB_TOPIC where id in :ids", new { ids = new[] { 1, 2, 3 } });
|
||||||
|
var t7 = g.oracle.Ado.Query<xxx>("select * from TB_TOPIC where id in :ids", new { ids = new List<int>(new[] { 1, 2, 3 }) });
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void QueryMultipline()
|
||||||
|
{
|
||||||
|
//var t3 = g.oracle.Ado.Query<xxx, (int, string, string), dynamic>("select * from \"TB_TOPIC\"; select * from \"TB_TOPIC\"; select * from \"TB_TOPIC\"");
|
||||||
|
}
|
||||||
|
|
||||||
|
class xxx
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Path { get; set; }
|
||||||
|
public string Title2 { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace FreeSql.Tests.OracleOledb
|
||||||
|
{
|
||||||
|
public class OracleOledbAopTest
|
||||||
|
{
|
||||||
|
|
||||||
|
class TestAuditValue
|
||||||
|
{
|
||||||
|
public Guid id { get; set; }
|
||||||
|
[Now]
|
||||||
|
public DateTime createtime { get; set; }
|
||||||
|
}
|
||||||
|
class NowAttribute: Attribute { }
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void AuditValue()
|
||||||
|
{
|
||||||
|
var date = DateTime.Now.Date;
|
||||||
|
var item = new TestAuditValue();
|
||||||
|
|
||||||
|
EventHandler<Aop.AuditValueEventArgs> audit = (s, e) =>
|
||||||
|
{
|
||||||
|
if (e.Property.GetCustomAttribute<NowAttribute>(false) != null)
|
||||||
|
e.Value = DateTime.Now.Date;
|
||||||
|
};
|
||||||
|
g.oracle.Aop.AuditValue += audit;
|
||||||
|
|
||||||
|
g.oracle.Insert(item).ExecuteAffrows();
|
||||||
|
|
||||||
|
g.oracle.Aop.AuditValue -= audit;
|
||||||
|
|
||||||
|
Assert.Equal(item.createtime, date);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,603 @@
|
|||||||
|
using FreeSql.DataAnnotations;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Security.Cryptography.X509Certificates;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace FreeSql.Tests.OracleOledb
|
||||||
|
{
|
||||||
|
public class OracleOledbCodeFirstTest
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public void Test_0String()
|
||||||
|
{
|
||||||
|
var fsql = g.oracle;
|
||||||
|
fsql.Delete<test_0string01>().Where("1=1").ExecuteAffrows();
|
||||||
|
|
||||||
|
Assert.Equal(1, fsql.Insert(new test_0string01 { name = @"1.0000\0.0000\0.0000\0.0000\1.0000\0.0000" }).ExecuteAffrows());
|
||||||
|
Assert.Equal(1, fsql.Insert(new test_0string01 { name = @"1.0000\0.0000\0.0000\0.0000\1.0000\0.0000" }).NoneParameter().ExecuteAffrows());
|
||||||
|
|
||||||
|
var list = fsql.Select<test_0string01>().ToList();
|
||||||
|
Assert.Equal(2, list.Count);
|
||||||
|
Assert.Equal(@"1.0000\0.0000\0.0000\0.0000\1.0000\0.0000", list[0].name);
|
||||||
|
Assert.Equal(@"1.0000\0.0000\0.0000\0.0000\1.0000\0.0000", list[1].name);
|
||||||
|
}
|
||||||
|
class test_0string01
|
||||||
|
{
|
||||||
|
public Guid id { get; set; }
|
||||||
|
public string name { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void InsertUpdateParameter()
|
||||||
|
{
|
||||||
|
var fsql = g.oracle;
|
||||||
|
fsql.CodeFirst.SyncStructure<ts_iupstr_bak>();
|
||||||
|
var item = new ts_iupstr { id = Guid.NewGuid(), title = string.Join(",", Enumerable.Range(0, 2000).Select(a => "我是中国人")) };
|
||||||
|
Assert.Equal(1, fsql.Insert(item).ExecuteAffrows());
|
||||||
|
var find = fsql.Select<ts_iupstr>().Where(a => a.id == item.id).First();
|
||||||
|
Assert.NotNull(find);
|
||||||
|
Assert.Equal(find.id, item.id);
|
||||||
|
Assert.Equal(find.title, item.title);
|
||||||
|
}
|
||||||
|
[Table(Name = "ts_iupstr_bak", DisableSyncStructure = true)]
|
||||||
|
class ts_iupstr
|
||||||
|
{
|
||||||
|
public Guid id { get; set; }
|
||||||
|
public string title { get; set; }
|
||||||
|
}
|
||||||
|
class ts_iupstr_bak
|
||||||
|
{
|
||||||
|
public Guid id { get; set; }
|
||||||
|
[Column(StringLength = -1)]
|
||||||
|
public string title { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void StringNullToEmpty()
|
||||||
|
{
|
||||||
|
using (var fsql = new FreeSql.FreeSqlBuilder()
|
||||||
|
.UseConnectionString(FreeSql.DataType.Oracle, "Provider=OraOLEDB.Oracle;user id=9user;password=123456;data source=//127.0.0.1:1521/XE;Pooling=true;Max Pool Size=5;min pool size=1")
|
||||||
|
.UseAutoSyncStructure(true)
|
||||||
|
//.UseGenerateCommandParameterWithLambda(true)
|
||||||
|
.UseLazyLoading(true)
|
||||||
|
.UseNameConvert(FreeSql.Internal.NameConvertType.ToUpper)
|
||||||
|
//.UseNoneCommandParameter(true)
|
||||||
|
|
||||||
|
.UseMonitorCommand(
|
||||||
|
cmd => Trace.WriteLine("\r\n线程" + Thread.CurrentThread.ManagedThreadId + ": " + cmd.CommandText) //监听SQL命令对象,在执行前
|
||||||
|
//, (cmd, traceLog) => Console.WriteLine(traceLog)
|
||||||
|
)
|
||||||
|
.Build())
|
||||||
|
{
|
||||||
|
var repo = fsql.GetRepository<TS_SL361, long>();
|
||||||
|
|
||||||
|
var item1 = new TS_SL361 { CreatorId = "" };
|
||||||
|
repo.Insert(item1);
|
||||||
|
var item2 = repo.Get(item1.Id);
|
||||||
|
|
||||||
|
Assert.Null(item2.CreatorId);
|
||||||
|
|
||||||
|
fsql.Aop.AuditDataReader += (_, e) =>
|
||||||
|
{
|
||||||
|
if (e.DataReader.GetFieldType(e.Index) == typeof(string) && e.Value == DBNull.Value)
|
||||||
|
e.Value = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
item1 = new TS_SL361 { CreatorId = "" };
|
||||||
|
repo.Insert(item1);
|
||||||
|
item2 = repo.Get(item1.Id);
|
||||||
|
|
||||||
|
Assert.Equal(item1.CreatorId, item2.CreatorId);
|
||||||
|
|
||||||
|
fsql.Aop.AuditDataReader -= fsql.Aop.AuditDataReaderHandler;
|
||||||
|
|
||||||
|
item1 = new TS_SL361 { CreatorId = "" };
|
||||||
|
repo.Insert(item1);
|
||||||
|
item2 = repo.Get(item1.Id);
|
||||||
|
|
||||||
|
Assert.Null(item2.CreatorId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
class TS_SNTE
|
||||||
|
{
|
||||||
|
[Column(IsIdentity = true)]
|
||||||
|
public long Id { get; set; }
|
||||||
|
public string CreatorId { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void StringLength36()
|
||||||
|
{
|
||||||
|
var repo = g.oracle.GetRepository<TS_SL361, long>();
|
||||||
|
|
||||||
|
var item1 = new TS_SL361 { CreatorId = "xxx '123 " };
|
||||||
|
repo.Insert(item1);
|
||||||
|
var item2 = repo.Get(item1.Id);
|
||||||
|
|
||||||
|
Assert.Equal(item1.CreatorId, item2.CreatorId);
|
||||||
|
}
|
||||||
|
class TS_SL361
|
||||||
|
{
|
||||||
|
[Column(IsIdentity = true)]
|
||||||
|
public long Id { get; set; }
|
||||||
|
[Column(StringLength = 36)]
|
||||||
|
public string CreatorId { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void NClob_StringLength_1()
|
||||||
|
{
|
||||||
|
var str1 = string.Join(",", Enumerable.Range(0, 10000).Select(a => "我是中国人"));
|
||||||
|
|
||||||
|
var item1 = new TS_NCLB02 { Data = str1 };
|
||||||
|
Assert.Equal(1, g.oracle.Insert(item1).ExecuteAffrows());
|
||||||
|
|
||||||
|
var item2 = g.oracle.Select<TS_NCLB02>().Where(a => a.Id == item1.Id).First();
|
||||||
|
Assert.Equal(str1, item2.Data);
|
||||||
|
|
||||||
|
//NoneParameter
|
||||||
|
item1 = new TS_NCLB02 { Data = str1 };
|
||||||
|
Assert.Equal(1, g.oracle.Insert(item1).NoneParameter().ExecuteAffrows());
|
||||||
|
//Oracle.ManagedDataAccess.Client.OracleException:“ORA-01704: 字符串文字太长”
|
||||||
|
|
||||||
|
item2 = g.oracle.Select<TS_NCLB02>().Where(a => a.Id == item1.Id).First();
|
||||||
|
Assert.Equal(str1, item2.Data);
|
||||||
|
}
|
||||||
|
class TS_NCLB02
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
[Column(StringLength = - 1)]
|
||||||
|
public string Data { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void NClob()
|
||||||
|
{
|
||||||
|
var str1 = string.Join(",", Enumerable.Range(0, 10000).Select(a => "我是中国人"));
|
||||||
|
|
||||||
|
var item1 = new TS_NCLB01 { Data = str1 };
|
||||||
|
Assert.Equal(1, g.oracle.Insert(item1).ExecuteAffrows());
|
||||||
|
|
||||||
|
var item2 = g.oracle.Select<TS_NCLB01>().Where(a => a.Id == item1.Id).First();
|
||||||
|
Assert.Equal(str1, item2.Data);
|
||||||
|
|
||||||
|
//NoneParameter
|
||||||
|
item1 = new TS_NCLB01 { Data = str1 };
|
||||||
|
Assert.Equal(1, g.oracle.Insert(item1).NoneParameter().ExecuteAffrows());
|
||||||
|
//Oracle.ManagedDataAccess.Client.OracleException:“ORA-01704: 字符串文字太长”
|
||||||
|
|
||||||
|
item2 = g.oracle.Select<TS_NCLB01>().Where(a => a.Id == item1.Id).First();
|
||||||
|
Assert.Equal(str1, item2.Data);
|
||||||
|
}
|
||||||
|
class TS_NCLB01
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
[Column(DbType = "nclob")]
|
||||||
|
public string Data { get; set; }
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Clob()
|
||||||
|
{
|
||||||
|
var str1 = string.Join(",", Enumerable.Range(0, 10000).Select(a => "我是中国人"));
|
||||||
|
|
||||||
|
var item1 = new TS_CLB01 { Data = str1 };
|
||||||
|
Assert.Equal(1, g.oracle.Insert(item1).ExecuteAffrows());
|
||||||
|
|
||||||
|
var item2 = g.oracle.Select<TS_CLB01>().Where(a => a.Id == item1.Id).First();
|
||||||
|
Assert.Equal(str1, item2.Data);
|
||||||
|
|
||||||
|
//NoneParameter
|
||||||
|
item1 = new TS_CLB01 { Data = str1 };
|
||||||
|
Assert.Equal(1, g.oracle.Insert(item1).NoneParameter().ExecuteAffrows());
|
||||||
|
//Oracle.ManagedDataAccess.Client.OracleException:“ORA-01704: 字符串文字太长”
|
||||||
|
|
||||||
|
item2 = g.oracle.Select<TS_CLB01>().Where(a => a.Id == item1.Id).First();
|
||||||
|
Assert.Equal(str1, item2.Data);
|
||||||
|
}
|
||||||
|
class TS_CLB01
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
[Column(DbType = "clob")]
|
||||||
|
public string Data { get; set; }
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Blob()
|
||||||
|
{
|
||||||
|
var str1 = string.Join(",", Enumerable.Range(0, 10000).Select(a => "我是中国人"));
|
||||||
|
var data1 = Encoding.UTF8.GetBytes(str1);
|
||||||
|
|
||||||
|
var item1 = new TS_BLB01 { Data = data1 };
|
||||||
|
Assert.Equal(1, g.oracle.Insert(item1).ExecuteAffrows());
|
||||||
|
|
||||||
|
var item2 = g.oracle.Select<TS_BLB01>().Where(a => a.Id == item1.Id).First();
|
||||||
|
Assert.Equal(item1.Data.Length, item2.Data.Length);
|
||||||
|
|
||||||
|
var str2 = Encoding.UTF8.GetString(item2.Data);
|
||||||
|
Assert.Equal(str1, str2);
|
||||||
|
|
||||||
|
//NoneParameter
|
||||||
|
item1 = new TS_BLB01 { Data = data1 };
|
||||||
|
Assert.Equal(1, g.oracle.Insert(item1).NoneParameter().ExecuteAffrows());
|
||||||
|
//Oracle.ManagedDataAccess.Client.OracleException:“ORA-01704: 字符串文字太长”
|
||||||
|
|
||||||
|
item2 = g.oracle.Select<TS_BLB01>().Where(a => a.Id == item1.Id).First();
|
||||||
|
Assert.Equal(item1.Data.Length, item2.Data.Length);
|
||||||
|
|
||||||
|
str2 = Encoding.UTF8.GetString(item2.Data);
|
||||||
|
Assert.Equal(str1, str2);
|
||||||
|
|
||||||
|
Assert.Equal(1, g.oracle.InsertOrUpdate<TS_BLB01>().SetSource(new TS_BLB01 { Data = data1 }).ExecuteAffrows());
|
||||||
|
item2 = g.oracle.Select<TS_BLB01>().Where(a => a.Id == item1.Id).First();
|
||||||
|
Assert.Equal(item1.Data.Length, item2.Data.Length);
|
||||||
|
|
||||||
|
str2 = Encoding.UTF8.GetString(item2.Data);
|
||||||
|
Assert.Equal(str1, str2);
|
||||||
|
}
|
||||||
|
class TS_BLB01
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
[MaxLength(-1)]
|
||||||
|
public byte[] Data { get; set; }
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void StringLength()
|
||||||
|
{
|
||||||
|
var dll = g.oracle.CodeFirst.GetComparisonDDLStatements<TS_SLTB>();
|
||||||
|
g.oracle.CodeFirst.SyncStructure<TS_SLTB>();
|
||||||
|
}
|
||||||
|
class TS_SLTB
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
[Column(StringLength = 50)]
|
||||||
|
public string Title { get; set; }
|
||||||
|
|
||||||
|
[Column(IsNullable = false, StringLength = 50)]
|
||||||
|
public string TitleSub { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void 数字表_字段()
|
||||||
|
{
|
||||||
|
var sql = g.oracle.CodeFirst.GetComparisonDDLStatements<测试数字表>();
|
||||||
|
g.oracle.CodeFirst.SyncStructure<测试数字表>();
|
||||||
|
|
||||||
|
var item = new 测试数字表
|
||||||
|
{
|
||||||
|
标题 = "测试标题",
|
||||||
|
创建时间 = DateTime.Now
|
||||||
|
};
|
||||||
|
Assert.Equal(1, g.oracle.Insert<测试数字表>().AppendData(item).ExecuteAffrows());
|
||||||
|
Assert.NotEqual(Guid.Empty, item.编号);
|
||||||
|
var item2 = g.oracle.Select<测试数字表>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新";
|
||||||
|
Assert.Equal(1, g.oracle.Update<测试数字表>().SetSource(item).ExecuteAffrows());
|
||||||
|
item2 = g.oracle.Select<测试数字表>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新_repo";
|
||||||
|
var repo = g.oracle.GetRepository<测试数字表>();
|
||||||
|
Assert.Equal(1, repo.Update(item));
|
||||||
|
item2 = g.oracle.Select<测试数字表>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新_repo22";
|
||||||
|
Assert.Equal(1, repo.Update(item));
|
||||||
|
item2 = g.oracle.Select<测试数字表>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
}
|
||||||
|
[Table(Name = "123tb")]
|
||||||
|
[OraclePrimaryKeyName("pk1_123tb")]
|
||||||
|
class 测试数字表
|
||||||
|
{
|
||||||
|
[Column(IsPrimary = true, Name = "123id")]
|
||||||
|
public Guid 编号 { get; set; }
|
||||||
|
|
||||||
|
[Column(Name = "123title")]
|
||||||
|
public string 标题 { get; set; }
|
||||||
|
|
||||||
|
[Column(Name = "123time")]
|
||||||
|
public DateTime 创建时间 { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void 中文表_字段()
|
||||||
|
{
|
||||||
|
var sql = g.oracle.CodeFirst.GetComparisonDDLStatements<测试中文表>();
|
||||||
|
g.oracle.CodeFirst.SyncStructure<测试中文表>();
|
||||||
|
|
||||||
|
var item = new 测试中文表
|
||||||
|
{
|
||||||
|
标题 = "测试标题",
|
||||||
|
创建时间 = DateTime.Now
|
||||||
|
};
|
||||||
|
Assert.Equal(1, g.oracle.Insert<测试中文表>().AppendData(item).ExecuteAffrows());
|
||||||
|
Assert.NotEqual(Guid.Empty, item.编号);
|
||||||
|
var item2 = g.oracle.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新";
|
||||||
|
Assert.Equal(1, g.oracle.Update<测试中文表>().SetSource(item).ExecuteAffrows());
|
||||||
|
item2 = g.oracle.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新_repo";
|
||||||
|
var repo = g.oracle.GetRepository<测试中文表>();
|
||||||
|
Assert.Equal(1, repo.Update(item));
|
||||||
|
item2 = g.oracle.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
|
item.标题 = "测试标题更新_repo22";
|
||||||
|
Assert.Equal(1, repo.Update(item));
|
||||||
|
item2 = g.oracle.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal(item.编号, item2.编号);
|
||||||
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
}
|
||||||
|
class 测试中文表
|
||||||
|
{
|
||||||
|
[Column(IsPrimary = true)]
|
||||||
|
public Guid 编号 { get; set; }
|
||||||
|
|
||||||
|
public string 标题 { get; set; }
|
||||||
|
|
||||||
|
[Column(ServerTime = DateTimeKind.Local, CanUpdate = false)]
|
||||||
|
public DateTime 创建时间 { get; set; }
|
||||||
|
|
||||||
|
[Column(ServerTime = DateTimeKind.Local)]
|
||||||
|
public DateTime 更新时间 { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void AddUniques()
|
||||||
|
{
|
||||||
|
var sql = g.oracle.CodeFirst.GetComparisonDDLStatements<AddUniquesInfo>();
|
||||||
|
g.oracle.CodeFirst.SyncStructure<AddUniquesInfo>();
|
||||||
|
//g.oracle.CodeFirst.SyncStructure(typeof(AddUniquesInfo), "AddUniquesInfo1");
|
||||||
|
}
|
||||||
|
[Table(Name = "AddUniquesInfo", OldName = "AddUniquesInfo2")]
|
||||||
|
[Index("uk_phone", "phone", true)]
|
||||||
|
[Index("uk_group_index", "group,index", true)]
|
||||||
|
[Index("uk_group_index22", "group, index22 desc", true)]
|
||||||
|
class AddUniquesInfo
|
||||||
|
{
|
||||||
|
public Guid id { get; set; }
|
||||||
|
public string phone { get; set; }
|
||||||
|
|
||||||
|
public string group { get; set; }
|
||||||
|
public int index { get; set; }
|
||||||
|
public string index22 { get; set; }
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void AddField()
|
||||||
|
{
|
||||||
|
var sql = g.oracle.CodeFirst.GetComparisonDDLStatements<TopicAddField>();
|
||||||
|
|
||||||
|
var id = g.oracle.Insert<TopicAddField>().AppendData(new TopicAddField { }).ExecuteIdentity();
|
||||||
|
|
||||||
|
//var inserted = g.oracle.Insert<TopicAddField>().AppendData(new TopicAddField { }).ExecuteInserted();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Table(Name = "TopicAddField", OldName = "xxxtb.TopicAddField")]
|
||||||
|
public class TopicAddField
|
||||||
|
{
|
||||||
|
[Column(IsIdentity = true)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public string name { get; set; }
|
||||||
|
|
||||||
|
[Column(DbType = "varchar2(200 char) not null", OldName = "title")]
|
||||||
|
public string title2 { get; set; } = "10";
|
||||||
|
|
||||||
|
[Column(IsIgnore = true)]
|
||||||
|
public DateTime ct { get; set; } = DateTime.Now;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void GetComparisonDDLStatements()
|
||||||
|
{
|
||||||
|
|
||||||
|
var sql = g.oracle.CodeFirst.GetComparisonDDLStatements<TableAllType>();
|
||||||
|
Assert.True(string.IsNullOrEmpty(sql)); //测试运行两次后
|
||||||
|
//sql = g.oracle.CodeFirst.GetComparisonDDLStatements<Tb_alltype>();
|
||||||
|
}
|
||||||
|
|
||||||
|
IInsert<TableUnsignedType> insertUnsigned => g.oracle.Insert<TableUnsignedType>();
|
||||||
|
ISelect<TableUnsignedType> selectUnsigned => g.oracle.Select<TableUnsignedType>();
|
||||||
|
[Fact]
|
||||||
|
public void CurdUnsignedField()
|
||||||
|
{
|
||||||
|
var item = new TableUnsignedType { };
|
||||||
|
item.Id = (int)insertUnsigned.AppendData(item).ExecuteIdentity();
|
||||||
|
|
||||||
|
var newitem = selectUnsigned.Where(a => a.Id == item.Id).ToOne();
|
||||||
|
|
||||||
|
var item2 = new TableUnsignedType
|
||||||
|
{
|
||||||
|
Byte = 254,
|
||||||
|
SByte = 100,
|
||||||
|
UInt = uint.MaxValue,
|
||||||
|
UIntNullable = uint.MinValue,
|
||||||
|
ULong = ulong.MaxValue,
|
||||||
|
ULongNullable = ulong.MinValue,
|
||||||
|
UShort = ushort.MaxValue,
|
||||||
|
UShortNullable = ushort.MinValue,
|
||||||
|
};
|
||||||
|
var sqlPar = insertUnsigned.AppendData(item2).ToSql();
|
||||||
|
var sqlText = insertUnsigned.AppendData(item2).NoneParameter().ToSql();
|
||||||
|
var item3NP = insertUnsigned.AppendData(item2).NoneParameter().ExecuteIdentity();
|
||||||
|
|
||||||
|
item2.Id = (int)insertUnsigned.AppendData(item2).ExecuteIdentity();
|
||||||
|
var newitem2 = selectUnsigned.Where(a => a.Id == item2.Id).ToOne();
|
||||||
|
|
||||||
|
item2.Id = (int)insertUnsigned.NoneParameter().AppendData(item2).ExecuteIdentity();
|
||||||
|
newitem2 = selectUnsigned.Where(a => a.Id == item2.Id).ToOne();
|
||||||
|
|
||||||
|
var items = selectUnsigned.ToList();
|
||||||
|
var itemstb = selectUnsigned.ToDataTable();
|
||||||
|
}
|
||||||
|
class TableUnsignedType
|
||||||
|
{
|
||||||
|
[Column(IsIdentity = true, IsPrimary = true)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public sbyte SByte { get; set; }
|
||||||
|
public byte Byte { get; set; }
|
||||||
|
public ushort UShort { get; set; }
|
||||||
|
public uint UInt { get; set; }
|
||||||
|
public ulong ULong { get; set; }
|
||||||
|
|
||||||
|
public ushort? UShortNullable { get; set; }
|
||||||
|
public uint? UIntNullable { get; set; }
|
||||||
|
public ulong? ULongNullable { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
IInsert<TableAllType> insert => g.oracle.Insert<TableAllType>();
|
||||||
|
ISelect<TableAllType> select => g.oracle.Select<TableAllType>();
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void CurdAllField()
|
||||||
|
{
|
||||||
|
var item = new TableAllType { };
|
||||||
|
item.Id = (int)insert.AppendData(item).ExecuteIdentity();
|
||||||
|
|
||||||
|
var newitem = select.Where(a => a.Id == item.Id).ToOne();
|
||||||
|
|
||||||
|
var item2 = new TableAllType
|
||||||
|
{
|
||||||
|
Bool = true,
|
||||||
|
BoolNullable = true,
|
||||||
|
Byte = 254,
|
||||||
|
ByteNullable = 127,
|
||||||
|
Bytes = Encoding.UTF8.GetBytes("我是中国人"),
|
||||||
|
DateTime = DateTime.Now,
|
||||||
|
DateTimeNullable = DateTime.Now.AddHours(-1),
|
||||||
|
Decimal = 99.99M,
|
||||||
|
DecimalNullable = 99.98M,
|
||||||
|
Double = 999.99,
|
||||||
|
DoubleNullable = 999.98,
|
||||||
|
Enum1 = TableAllTypeEnumType1.e5,
|
||||||
|
Enum1Nullable = TableAllTypeEnumType1.e3,
|
||||||
|
Enum2 = TableAllTypeEnumType2.f2,
|
||||||
|
Enum2Nullable = TableAllTypeEnumType2.f3,
|
||||||
|
Float = 19.99F,
|
||||||
|
FloatNullable = 19.98F,
|
||||||
|
Guid = Guid.NewGuid(),
|
||||||
|
GuidNullable = Guid.NewGuid(),
|
||||||
|
Int = int.MaxValue,
|
||||||
|
IntNullable = int.MinValue,
|
||||||
|
SByte = 100,
|
||||||
|
SByteNullable = 99,
|
||||||
|
Short = short.MaxValue,
|
||||||
|
ShortNullable = short.MinValue,
|
||||||
|
String = "我是中国人string'\\?!@#$%^&*()_+{}}{~?><<>",
|
||||||
|
Char = 'X',
|
||||||
|
UInt = uint.MaxValue,
|
||||||
|
UIntNullable = uint.MinValue,
|
||||||
|
ULong = ulong.MaxValue,
|
||||||
|
ULongNullable = ulong.MinValue,
|
||||||
|
UShort = ushort.MaxValue,
|
||||||
|
UShortNullable = ushort.MinValue,
|
||||||
|
testFielLongNullable = long.MinValue
|
||||||
|
};
|
||||||
|
var sqlPar = insert.AppendData(item2).ToSql();
|
||||||
|
var sqlText = insert.AppendData(item2).NoneParameter().ToSql();
|
||||||
|
var item3NP = insert.AppendData(item2).NoneParameter().ExecuteIdentity();
|
||||||
|
|
||||||
|
item2.Id = (int)insert.AppendData(item2).ExecuteIdentity();
|
||||||
|
var newitem2 = select.Where(a => a.Id == item2.Id).ToOne();
|
||||||
|
Assert.Equal(item2.String, newitem2.String);
|
||||||
|
Assert.Equal(item2.Char, newitem2.Char);
|
||||||
|
|
||||||
|
item2.Id = (int)insert.NoneParameter().AppendData(item2).ExecuteIdentity();
|
||||||
|
newitem2 = select.Where(a => a.Id == item2.Id).ToOne();
|
||||||
|
Assert.Equal(item2.String, newitem2.String);
|
||||||
|
Assert.Equal(item2.Char, newitem2.Char);
|
||||||
|
|
||||||
|
var items = select.ToList();
|
||||||
|
var itemstb = select.ToDataTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Table(Name = "tb_alltype")]
|
||||||
|
class TableAllType
|
||||||
|
{
|
||||||
|
[Column(IsIdentity = true, IsPrimary = true)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public string id2 { get; set; } = "id2=10";
|
||||||
|
|
||||||
|
public bool Bool { get; set; }
|
||||||
|
public sbyte SByte { get; set; }
|
||||||
|
public short Short { get; set; }
|
||||||
|
public int Int { get; set; }
|
||||||
|
public long Long { get; set; }
|
||||||
|
public byte Byte { get; set; }
|
||||||
|
public ushort UShort { get; set; }
|
||||||
|
public uint UInt { get; set; }
|
||||||
|
public ulong ULong { get; set; }
|
||||||
|
public double Double { get; set; }
|
||||||
|
public float Float { get; set; }
|
||||||
|
public decimal Decimal { get; set; }
|
||||||
|
|
||||||
|
[Column(ServerTime = DateTimeKind.Local)]
|
||||||
|
public DateTime DateTime { get; set; }
|
||||||
|
[Column(ServerTime = DateTimeKind.Local)]
|
||||||
|
public DateTime DateTimeOffSet { get; set; }
|
||||||
|
|
||||||
|
public byte[] Bytes { get; set; }
|
||||||
|
public string String { get; set; }
|
||||||
|
public char Char { get; set; }
|
||||||
|
public Guid Guid { get; set; }
|
||||||
|
|
||||||
|
public bool? BoolNullable { get; set; }
|
||||||
|
public sbyte? SByteNullable { get; set; }
|
||||||
|
public short? ShortNullable { get; set; }
|
||||||
|
public int? IntNullable { get; set; }
|
||||||
|
public long? testFielLongNullable { get; set; }
|
||||||
|
public byte? ByteNullable { get; set; }
|
||||||
|
public ushort? UShortNullable { get; set; }
|
||||||
|
public uint? UIntNullable { get; set; }
|
||||||
|
public ulong? ULongNullable { get; set; }
|
||||||
|
public double? DoubleNullable { get; set; }
|
||||||
|
public float? FloatNullable { get; set; }
|
||||||
|
public decimal? DecimalNullable { get; set; }
|
||||||
|
|
||||||
|
[Column(ServerTime = DateTimeKind.Local)]
|
||||||
|
public DateTime? DateTimeNullable { get; set; }
|
||||||
|
[Column(ServerTime = DateTimeKind.Local)]
|
||||||
|
public DateTime? DateTimeOffSetNullable { get; set; }
|
||||||
|
|
||||||
|
public Guid? GuidNullable { get; set; }
|
||||||
|
|
||||||
|
public TableAllTypeEnumType1 Enum1 { get; set; }
|
||||||
|
public TableAllTypeEnumType1? Enum1Nullable { get; set; }
|
||||||
|
public TableAllTypeEnumType2 Enum2 { get; set; }
|
||||||
|
public TableAllTypeEnumType2? Enum2Nullable { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum TableAllTypeEnumType1 { e1, e2, e3, e5 }
|
||||||
|
[Flags] public enum TableAllTypeEnumType2 { f1, f2, f3 }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,67 @@
|
|||||||
|
using FreeSql.DataAnnotations;
|
||||||
|
using System;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace FreeSql.Tests.OracleOledb
|
||||||
|
{
|
||||||
|
public class OracleOledbDbFirstTest
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public void GetDatabases()
|
||||||
|
{
|
||||||
|
var t1 = g.oracle.DbFirst.GetDatabases();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void GetTablesByDatabase()
|
||||||
|
{
|
||||||
|
var t2 = g.oracle.DbFirst.GetTablesByDatabase();
|
||||||
|
Assert.True(t2.Count > 0);
|
||||||
|
//var tb = g.oracle.Ado.ExecuteArray(System.Data.CommandType.Text, "select * from \"tb_dbfirst\"");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void GetTableByName()
|
||||||
|
{
|
||||||
|
var fsql = g.oracle;
|
||||||
|
var t1 = fsql.DbFirst.GetTableByName("tb_alltype");
|
||||||
|
var t2 = fsql.DbFirst.GetTableByName("9user.tb_alltype");
|
||||||
|
Assert.NotNull(t1);
|
||||||
|
Assert.NotNull(t2);
|
||||||
|
Assert.True(t1.Columns.Count > 0);
|
||||||
|
Assert.True(t2.Columns.Count > 0);
|
||||||
|
Assert.Equal(t1.Columns.Count, t2.Columns.Count);
|
||||||
|
var t3 = fsql.DbFirst.GetTableByName("notexists_tb");
|
||||||
|
Assert.Null(t3);
|
||||||
|
|
||||||
|
var t4 = fsql.DbFirst.GetTableByName("V_DTOS_DT");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void ExistsTable()
|
||||||
|
{
|
||||||
|
var fsql = g.oracle;
|
||||||
|
Assert.False(fsql.DbFirst.ExistsTable("test_existstb01"));
|
||||||
|
Assert.False(fsql.DbFirst.ExistsTable("9user.test_existstb01"));
|
||||||
|
Assert.False(fsql.DbFirst.ExistsTable("test_existstb01", false));
|
||||||
|
Assert.False(fsql.DbFirst.ExistsTable("9user.test_existstb01", false));
|
||||||
|
fsql.CodeFirst.SyncStructure(typeof(test_existstb01));
|
||||||
|
Assert.True(fsql.DbFirst.ExistsTable("test_existstb01"));
|
||||||
|
Assert.True(fsql.DbFirst.ExistsTable("9user.test_existstb01"));
|
||||||
|
Assert.False(fsql.DbFirst.ExistsTable("test_existstb01", false));
|
||||||
|
Assert.False(fsql.DbFirst.ExistsTable("9user.test_existstb01", false));
|
||||||
|
fsql.Ado.ExecuteNonQuery("drop table test_existstb01");
|
||||||
|
|
||||||
|
Assert.False(fsql.DbFirst.ExistsTable("9user.test_existstb01"));
|
||||||
|
Assert.False(fsql.DbFirst.ExistsTable("9user.test_existstb01", false));
|
||||||
|
fsql.CodeFirst.SyncStructure(typeof(test_existstb01), "9user.test_existstb01");
|
||||||
|
Assert.True(fsql.DbFirst.ExistsTable("9user.test_existstb01"));
|
||||||
|
Assert.False(fsql.DbFirst.ExistsTable("9user.test_existstb01", false));
|
||||||
|
fsql.Ado.ExecuteNonQuery("drop table \"9USER\".test_existstb01");
|
||||||
|
}
|
||||||
|
class test_existstb01
|
||||||
|
{
|
||||||
|
public Guid id { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,169 @@
|
|||||||
|
using FreeSql.DataAnnotations;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace FreeSql.Tests.OracleOledbExpression
|
||||||
|
{
|
||||||
|
public class ConvertTest
|
||||||
|
{
|
||||||
|
|
||||||
|
ISelect<Topic> select => g.oracle.Select<Topic>();
|
||||||
|
|
||||||
|
[Table(Name = "tb_topic")]
|
||||||
|
class Topic
|
||||||
|
{
|
||||||
|
[Column(IsIdentity = true, IsPrimary = true)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int Clicks { get; set; }
|
||||||
|
public int TypeGuid { get; set; }
|
||||||
|
public TestTypeInfo Type { get; set; }
|
||||||
|
public string Title { get; set; }
|
||||||
|
public DateTime CreateTime { get; set; }
|
||||||
|
}
|
||||||
|
class TestTypeInfo
|
||||||
|
{
|
||||||
|
public int Guid { get; set; }
|
||||||
|
public int ParentId { get; set; }
|
||||||
|
public TestTypeParentInfo Parent { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
}
|
||||||
|
class TestTypeParentInfo
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
public List<TestTypeInfo> Types { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void ToBoolean()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
//data.Add(select.Where(a => (Convert.ToBoolean(a.Clicks) ? 1 : 0) > 0).ToList());
|
||||||
|
//data.Add(select.Where(a => (bool.Parse(a.Clicks.ToString()) ? 1 : 0) > 0).ToList());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void ToByte()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => Convert.ToByte(a.Clicks % 255) > 0).ToList());
|
||||||
|
data.Add(select.Where(a => byte.Parse((a.Clicks % 255).ToString()) > 0).ToList());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void ToChar()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => Convert.ToChar(a.Clicks) == '1').ToList());
|
||||||
|
data.Add(select.Where(a => char.Parse(a.Clicks.ToString()) == '1').ToList());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void ToDateTime()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => Convert.ToDateTime(a.CreateTime.ToString()).Year > 0).ToList());
|
||||||
|
data.Add(select.Where(a => DateTime.Parse(a.CreateTime.ToString()).Year > 0).ToList());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void ToDecimal()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => Convert.ToDecimal(a.Clicks) > 0).ToList());
|
||||||
|
data.Add(select.Where(a => decimal.Parse(a.Clicks.ToString()) > 0).ToList());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void ToDouble()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => Convert.ToDouble(a.Clicks) > 0).ToList());
|
||||||
|
data.Add(select.Where(a => double.Parse(a.Clicks.ToString()) > 0).ToList());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void ToInt16()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => Convert.ToInt16(a.Clicks) > 0).ToList());
|
||||||
|
data.Add(select.Where(a => short.Parse(a.Clicks.ToString()) > 0).ToList());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void ToInt32()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => (int)a.Clicks > 0).ToList());
|
||||||
|
data.Add(select.Where(a => Convert.ToInt32(a.Clicks) > 0).ToList());
|
||||||
|
data.Add(select.Where(a => int.Parse(a.Clicks.ToString()) > 0).ToList());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void ToInt64()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => Convert.ToInt64(a.Clicks) > 0).ToList());
|
||||||
|
data.Add(select.Where(a => long.Parse(a.Clicks.ToString()) > 0).ToList());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void ToSByte()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => Convert.ToSByte(a.Clicks % 128) > 0).ToList());
|
||||||
|
data.Add(select.Where(a => sbyte.Parse((a.Clicks % 128).ToString()) > 0).ToList());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void ToSingle()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => Convert.ToSingle(a.Clicks) > 0).ToList());
|
||||||
|
data.Add(select.Where(a => float.Parse(a.Clicks.ToString()) > 0).ToList());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void this_ToString()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => Convert.ToString(a.Clicks).Equals("")).ToList());
|
||||||
|
data.Add(select.Where(a => a.Clicks.ToString().Equals("")).ToList());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void ToUInt16()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => Convert.ToUInt16(a.Clicks) > 0).ToList());
|
||||||
|
data.Add(select.Where(a => ushort.Parse(a.Clicks.ToString()) > 0).ToList());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void ToUInt32()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => Convert.ToUInt32(a.Clicks) > 0).ToList());
|
||||||
|
data.Add(select.Where(a => uint.Parse(a.Clicks.ToString()) > 0).ToList());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void ToUInt64()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => Convert.ToUInt64(a.Clicks) > 0).ToList());
|
||||||
|
data.Add(select.Where(a => ulong.Parse(a.Clicks.ToString()) > 0).ToList());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Guid_Parse()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => Guid.Parse(Guid.Empty.ToString()) == Guid.Empty).ToList());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Guid_NewGuid()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
//data.Add(select.OrderBy(a => Guid.NewGuid()).Limit(10).ToList());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Random()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => new Random().Next() > a.Clicks).Limit(10).ToList());
|
||||||
|
data.Add(select.Where(a => new Random().NextDouble() > a.Clicks).Limit(10).ToList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,732 @@
|
|||||||
|
using FreeSql.DataAnnotations;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace FreeSql.Tests.OracleOledbExpression
|
||||||
|
{
|
||||||
|
public class DateTimeTest
|
||||||
|
{
|
||||||
|
|
||||||
|
ISelect<Topic> select => g.oracle.Select<Topic>();
|
||||||
|
|
||||||
|
[Table(Name = "tb_topic111333")]
|
||||||
|
class Topic
|
||||||
|
{
|
||||||
|
[Column(IsIdentity = true, IsPrimary = true)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int Clicks { get; set; }
|
||||||
|
public int TypeGuid { get; set; }
|
||||||
|
public TestTypeInfo Type { get; set; }
|
||||||
|
public string Title { get; set; }
|
||||||
|
public DateTime CreateTime { get; set; } = DateTime.Now;
|
||||||
|
}
|
||||||
|
[Table(Name = "TestTypeInfo333")]
|
||||||
|
class TestTypeInfo
|
||||||
|
{
|
||||||
|
[Column(IsIdentity = true)]
|
||||||
|
public int Guid { get; set; }
|
||||||
|
public int ParentId { get; set; }
|
||||||
|
public TestTypeParentInfo Parent { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public DateTime Time { get; set; } = DateTime.Now;
|
||||||
|
}
|
||||||
|
[Table(Name = "TestTypeParentInf1")]
|
||||||
|
class TestTypeParentInfo
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
public List<TestTypeInfo> Types { get; set; }
|
||||||
|
public DateTime Time2 { get; set; } = DateTime.Now;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void this_ToString()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.ToString().Equals(DateTime.Now.ToString())).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Time.AddYears(1).ToString().Equals(DateTime.Now.ToString())).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Parent.Time2.AddYears(1).ToString().Equals(DateTime.Now.ToString())).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic111333` a
|
||||||
|
//WHERE ((date_format(a.`CreateTime`, '%Y-%m-%d %H:%i:%s.%f') = now()));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type
|
||||||
|
//WHERE ((date_format(date_add(a__Type.`Time`, interval (1) year), '%Y-%m-%d %H:%i:%s.%f') = now()));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent
|
||||||
|
//WHERE ((date_format(date_add(a__Type__Parent.`Time2`, interval (1) year), '%Y-%m-%d %H:%i:%s.%f') = now()))
|
||||||
|
|
||||||
|
g.oracle.Insert(new Topic()).ExecuteAffrows();
|
||||||
|
var dtn = DateTime.Parse("2020-1-1 0:0:0");
|
||||||
|
var dts = Enumerable.Range(1, 12).Select(a => dtn.AddMonths(a))
|
||||||
|
.Concat(Enumerable.Range(1, 31).Select(a => dtn.AddDays(a)))
|
||||||
|
.Concat(Enumerable.Range(1, 24).Select(a => dtn.AddHours(a)))
|
||||||
|
.Concat(Enumerable.Range(1, 60).Select(a => dtn.AddMinutes(a)))
|
||||||
|
.Concat(Enumerable.Range(1, 60).Select(a => dtn.AddSeconds(a)));
|
||||||
|
foreach (var dt in dts)
|
||||||
|
{
|
||||||
|
Assert.Equal(dt.ToString("yyyy-MM-dd HH:mm:ss.ffffff"), select.First(a => dt.ToString()));
|
||||||
|
Assert.Equal(dt.ToString("yyyy-MM-dd HH:mm:ss"), select.First(a => dt.ToString("yyyy-MM-dd HH:mm:ss")));
|
||||||
|
Assert.Equal(dt.ToString("yyyy-MM-dd HH:mm"), select.First(a => dt.ToString("yyyy-MM-dd HH:mm")));
|
||||||
|
Assert.Equal(dt.ToString("yyyy-MM-dd HH"), select.First(a => dt.ToString("yyyy-MM-dd HH")));
|
||||||
|
Assert.Equal(dt.ToString("yyyy-MM-dd"), select.First(a => dt.ToString("yyyy-MM-dd")));
|
||||||
|
Assert.Equal(dt.ToString("yyyy-MM"), select.First(a => dt.ToString("yyyy-MM")));
|
||||||
|
Assert.Equal(dt.ToString("yyyyMMddHHmmss"), select.First(a => dt.ToString("yyyyMMddHHmmss")));
|
||||||
|
Assert.Equal(dt.ToString("yyyyMMddHHmm"), select.First(a => dt.ToString("yyyyMMddHHmm")));
|
||||||
|
Assert.Equal(dt.ToString("yyyyMMddHH"), select.First(a => dt.ToString("yyyyMMddHH")));
|
||||||
|
Assert.Equal(dt.ToString("yyyyMMdd"), select.First(a => dt.ToString("yyyyMMdd")));
|
||||||
|
Assert.Equal(dt.ToString("yyyyMM"), select.First(a => dt.ToString("yyyyMM")));
|
||||||
|
Assert.Equal(dt.ToString("yyyy"), select.First(a => dt.ToString("yyyy")));
|
||||||
|
Assert.Equal(dt.ToString("HH:mm:ss"), select.First(a => dt.ToString("HH:mm:ss")));
|
||||||
|
Assert.Equal(dt.ToString("yyyy MM dd HH mm ss yy M d H hh h"), select.First(a => dt.ToString("yyyy MM dd HH mm ss yy M d H hh h")));
|
||||||
|
Assert.Equal(dt.ToString("yyyy MM dd HH mm ss yy M d H hh h m s"), select.First(a => dt.ToString("yyyy MM dd HH mm ss yy M d H hh h m s")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Now()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.Date == DateTime.Now.Date).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic111333` a
|
||||||
|
//WHERE (cast(date_format(a.`CreateTime`, '%Y-%m-%d') as datetime) = cast(date_format(now(), '%Y-%m-%d') as datetime))
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void UtcNow()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.Date == DateTime.UtcNow.Date).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic111333` a
|
||||||
|
//WHERE (cast(date_format(a.`CreateTime`, '%Y-%m-%d') as datetime) = cast(date_format(utc_timestamp(), '%Y-%m-%d') as datetime))
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void MinValue()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.Date == DateTime.MinValue.Date).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic111333` a
|
||||||
|
//WHERE (cast(date_format(a.`CreateTime`, '%Y-%m-%d') as datetime) = cast(date_format(cast('0001/1/1 0:00:00' as datetime), '%Y-%m-%d') as datetime))
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void MaxValue()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.Date == DateTime.MaxValue.Date).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic111333` a
|
||||||
|
//WHERE (cast(date_format(a.`CreateTime`, '%Y-%m-%d') as datetime) = cast(date_format(cast('9999/12/31 23:59:59' as datetime), '%Y-%m-%d') as datetime))
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Date()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.Date == DateTime.Now.Date).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Time.Date > DateTime.Now.Date).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Parent.Time2.Date > DateTime.Now.Date).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic111333` a
|
||||||
|
//WHERE (cast(date_format(a.`CreateTime`, '%Y-%m-%d') as datetime) = cast(date_format(now(), '%Y-%m-%d') as datetime));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type
|
||||||
|
//WHERE (cast(date_format(a__Type.`Time`, '%Y-%m-%d') as datetime) > cast(date_format(now(), '%Y-%m-%d') as datetime));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent
|
||||||
|
//WHERE (cast(date_format(a__Type__Parent.`Time2`, '%Y-%m-%d') as datetime) > cast(date_format(now(), '%Y-%m-%d') as datetime));
|
||||||
|
data.Add(select.Where(a => DateTime.Now.Subtract(a.CreateTime.Date).TotalSeconds > 0).ToList());
|
||||||
|
data.Add(select.Where(a => DateTime.Now.Subtract(a.Type.Time.Date).TotalSeconds > 0).ToList());
|
||||||
|
data.Add(select.Where(a => DateTime.Now.Subtract(a.Type.Parent.Time2.Date).TotalSeconds > 0).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic111333` a
|
||||||
|
//WHERE (((timestampdiff(microsecond, cast(date_format(a.`CreateTime`, '%Y-%m-%d') as datetime), now())) / 1000000) > 0);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type
|
||||||
|
//WHERE (((timestampdiff(microsecond, cast(date_format(a__Type.`Time`, '%Y-%m-%d') as datetime), now())) / 1000000) > 0);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent
|
||||||
|
//WHERE (((timestampdiff(microsecond, cast(date_format(a__Type__Parent.`Time2`, '%Y-%m-%d') as datetime), now())) / 1000000) > 0)
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void TimeOfDay()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.TimeOfDay == DateTime.Now.TimeOfDay).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Time.TimeOfDay > DateTime.Now.TimeOfDay).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Parent.Time2.TimeOfDay > DateTime.Now.TimeOfDay).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic111333` a
|
||||||
|
//WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (timestampdiff(microsecond, date_format(now(), '1970-1-1 %H:%i:%s.%f'), now()) + 62135596800000000));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type
|
||||||
|
//WHERE ((timestampdiff(microsecond, date_format(a__Type.`Time`, '1970-1-1 %H:%i:%s.%f'), a__Type.`Time`) + 62135596800000000) > (timestampdiff(microsecond, date_format(now(), '1970-1-1 %H:%i:%s.%f'), now()) + 62135596800000000));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent
|
||||||
|
//WHERE ((timestampdiff(microsecond, date_format(a__Type__Parent.`Time2`, '1970-1-1 %H:%i:%s.%f'), a__Type__Parent.`Time2`) + 62135596800000000) > (timestampdiff(microsecond, date_format(now(), '1970-1-1 %H:%i:%s.%f'), now()) + 62135596800000000))
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void DayOfWeek()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.DayOfWeek > DateTime.Now.DayOfWeek).ToList());
|
||||||
|
//data.Add(select.Where(a => a.Type.Time.DayOfWeek > DateTime.Now.DayOfWeek).ToList());
|
||||||
|
//data.Add(select.Where(a => a.Type.Parent.Time2.DayOfWeek > DateTime.Now.DayOfWeek).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic111333` a
|
||||||
|
//WHERE ((dayofweek(a.`CreateTime`) - 1) > (dayofweek(now()) - 1));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type
|
||||||
|
//WHERE ((dayofweek(a__Type.`Time`) - 1) > (dayofweek(now()) - 1));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent
|
||||||
|
//WHERE ((dayofweek(a__Type__Parent.`Time2`) - 1) > (dayofweek(now()) - 1))
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Day()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.Day > DateTime.Now.Day).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Time.Day > DateTime.Now.Day).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Parent.Time2.Day > DateTime.Now.Day).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic111333` a
|
||||||
|
//WHERE (dayofmonth(a.`CreateTime`) > dayofmonth(now()));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type
|
||||||
|
//WHERE (dayofmonth(a__Type.`Time`) > dayofmonth(now()));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent
|
||||||
|
//WHERE (dayofmonth(a__Type__Parent.`Time2`) > dayofmonth(now()))
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void DayOfYear()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.DayOfYear > DateTime.Now.DayOfYear).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Time.DayOfYear > DateTime.Now.DayOfYear).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Parent.Time2.DayOfYear > DateTime.Now.DayOfYear).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic111333` a
|
||||||
|
//WHERE (dayofyear(a.`CreateTime`) > dayofyear(now()));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type
|
||||||
|
//WHERE (dayofyear(a__Type.`Time`) > dayofyear(now()));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent
|
||||||
|
//WHERE (dayofyear(a__Type__Parent.`Time2`) > dayofyear(now()))
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Month()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.Month > DateTime.Now.Month).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Time.Month > DateTime.Now.Month).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Parent.Time2.Month > DateTime.Now.Month).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic111333` a
|
||||||
|
//WHERE (month(a.`CreateTime`) > month(now()));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type
|
||||||
|
//WHERE (month(a__Type.`Time`) > month(now()));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent
|
||||||
|
//WHERE (month(a__Type__Parent.`Time2`) > month(now()))
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Year()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.Year > DateTime.Now.Year).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Time.Year > DateTime.Now.Year).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Parent.Time2.Year > DateTime.Now.Year).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic111333` a
|
||||||
|
//WHERE (year(a.`CreateTime`) > year(now()));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type
|
||||||
|
//WHERE (year(a__Type.`Time`) > year(now()));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent
|
||||||
|
//WHERE (year(a__Type__Parent.`Time2`) > year(now()))
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Hour()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.Hour > DateTime.Now.Hour).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Time.Hour > DateTime.Now.Hour).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Parent.Time2.Hour > DateTime.Now.Hour).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic111333` a
|
||||||
|
//WHERE (hour(a.`CreateTime`) > hour(now()));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type
|
||||||
|
//WHERE (hour(a__Type.`Time`) > hour(now()));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent
|
||||||
|
//WHERE (hour(a__Type__Parent.`Time2`) > hour(now()))
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Minute()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.Minute > DateTime.Now.Minute).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Time.Minute > DateTime.Now.Minute).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Parent.Time2.Minute > DateTime.Now.Minute).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic111333` a
|
||||||
|
//WHERE (minute(a.`CreateTime`) > minute(now()));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type
|
||||||
|
//WHERE (minute(a__Type.`Time`) > minute(now()));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent
|
||||||
|
//WHERE (minute(a__Type__Parent.`Time2`) > minute(now()))
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Second()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.Second > DateTime.Now.Second).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Time.Second > DateTime.Now.Second).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Parent.Time2.Second > DateTime.Now.Second).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic111333` a
|
||||||
|
//WHERE (second(a.`CreateTime`) > second(now()));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type
|
||||||
|
//WHERE (second(a__Type.`Time`) > second(now()));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent
|
||||||
|
//WHERE (second(a__Type__Parent.`Time2`) > second(now()))
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Millisecond()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.Millisecond > DateTime.Now.Millisecond).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Time.Millisecond > DateTime.Now.Millisecond).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Parent.Time2.Millisecond > DateTime.Now.Millisecond).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic111333` a
|
||||||
|
//WHERE (floor(microsecond(a.`CreateTime`) / 1000) > floor(microsecond(now()) / 1000));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type
|
||||||
|
//WHERE (floor(microsecond(a__Type.`Time`) / 1000) > floor(microsecond(now()) / 1000));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent
|
||||||
|
//WHERE (floor(microsecond(a__Type__Parent.`Time2`) / 1000) > floor(microsecond(now()) / 1000))
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Ticks()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.Ticks > DateTime.Now.Ticks).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Time.Ticks > DateTime.Now.Ticks).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Parent.Time2.Ticks > DateTime.Now.Ticks).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic111333` a
|
||||||
|
//WHERE ((timestampdiff(microsecond, '1970-1-1', a.`CreateTime`) * 10 + 621355968000000000) > (timestampdiff(microsecond, '1970-1-1', now()) * 10 + 621355968000000000));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type
|
||||||
|
//WHERE ((timestampdiff(microsecond, '1970-1-1', a__Type.`Time`) * 10 + 621355968000000000) > (timestampdiff(microsecond, '1970-1-1', now()) * 10 + 621355968000000000));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent
|
||||||
|
//WHERE ((timestampdiff(microsecond, '1970-1-1', a__Type__Parent.`Time2`) * 10 + 621355968000000000) > (timestampdiff(microsecond, '1970-1-1', now()) * 10 + 621355968000000000))
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Add()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.Add(TimeSpan.FromDays(1)) > DateTime.Now).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Time.Add(TimeSpan.FromDays(1)) > DateTime.Now).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Parent.Time2.Add(TimeSpan.FromDays(1)) > DateTime.Now).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic111333` a
|
||||||
|
//WHERE (date_add(a.`CreateTime`, interval ((1 * 86400000000)) microsecond) > now());
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type
|
||||||
|
//WHERE (date_add(a__Type.`Time`, interval ((1 * 86400000000)) microsecond) > now());
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent
|
||||||
|
//WHERE (date_add(a__Type__Parent.`Time2`, interval ((1 * 86400000000)) microsecond) > now())
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void AddDays()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.AddDays(1) > DateTime.Now).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Time.AddDays(1) > DateTime.Now).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Parent.Time2.AddDays(1) > DateTime.Now).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic111333` a
|
||||||
|
//WHERE (date_add(a.`CreateTime`, interval (1) day) > now());
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type
|
||||||
|
//WHERE (date_add(a__Type.`Time`, interval (1) day) > now());
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent
|
||||||
|
//WHERE (date_add(a__Type__Parent.`Time2`, interval (1) day) > now())
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void AddHours()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.AddHours(1) > DateTime.Now).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Time.AddHours(1) > DateTime.Now).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Parent.Time2.AddHours(1) > DateTime.Now).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic111333` a
|
||||||
|
//WHERE (date_add(a.`CreateTime`, interval (1) hour) > now());
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type
|
||||||
|
//WHERE (date_add(a__Type.`Time`, interval (1) hour) > now());
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent
|
||||||
|
//WHERE (date_add(a__Type__Parent.`Time2`, interval (1) hour) > now())
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void AddMilliseconds()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.AddMilliseconds(1) > DateTime.Now).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Time.AddMilliseconds(1) > DateTime.Now).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Parent.Time2.AddMilliseconds(1) > DateTime.Now).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic111333` a
|
||||||
|
//WHERE (date_add(a.`CreateTime`, interval (1) * 1000 microsecond) > now());
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type
|
||||||
|
//WHERE (date_add(a__Type.`Time`, interval (1) * 1000 microsecond) > now());
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent
|
||||||
|
//WHERE (date_add(a__Type__Parent.`Time2`, interval (1) * 1000 microsecond) > now())
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void AddMinutes()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.AddMinutes(1) > DateTime.Now).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Time.AddMinutes(1) > DateTime.Now).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Parent.Time2.AddMinutes(1) > DateTime.Now).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic111333` a
|
||||||
|
//WHERE (date_add(a.`CreateTime`, interval (1) minute) > now());
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type
|
||||||
|
//WHERE (date_add(a__Type.`Time`, interval (1) minute) > now());
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent
|
||||||
|
//WHERE (date_add(a__Type__Parent.`Time2`, interval (1) minute) > now())
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void AddMonths()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.AddMonths(1) > DateTime.Now).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Time.AddMonths(1) > DateTime.Now).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Parent.Time2.AddMonths(1) > DateTime.Now).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic111333` a
|
||||||
|
//WHERE (date_add(a.`CreateTime`, interval (1) month) > now());
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type
|
||||||
|
//WHERE (date_add(a__Type.`Time`, interval (1) month) > now());
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent
|
||||||
|
//WHERE (date_add(a__Type__Parent.`Time2`, interval (1) month) > now())
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void AddSeconds()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.AddSeconds(1) > DateTime.Now).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Time.AddSeconds(1) > DateTime.Now).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Parent.Time2.AddSeconds(1) > DateTime.Now).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic111333` a
|
||||||
|
//WHERE (date_add(a.`CreateTime`, interval (1) second) > now());
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type
|
||||||
|
//WHERE (date_add(a__Type.`Time`, interval (1) second) > now());
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent
|
||||||
|
//WHERE (date_add(a__Type__Parent.`Time2`, interval (1) second) > now())
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void AddTicks()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.AddTicks(1) > DateTime.Now).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Time.AddTicks(1) > DateTime.Now).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Parent.Time2.AddTicks(1) > DateTime.Now).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic111333` a
|
||||||
|
//WHERE (date_add(a.`CreateTime`, interval (1) / 10 microsecond) > now());
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type
|
||||||
|
//WHERE (date_add(a__Type.`Time`, interval (1) / 10 microsecond) > now());
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent
|
||||||
|
//WHERE (date_add(a__Type__Parent.`Time2`, interval (1) / 10 microsecond) > now())
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void AddYears()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.AddYears(1) > DateTime.Now).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Time.AddYears(1) > DateTime.Now).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Parent.Time2.AddYears(1) > DateTime.Now).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic111333` a
|
||||||
|
//WHERE (date_add(a.`CreateTime`, interval (1) year) > now());
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type
|
||||||
|
//WHERE (date_add(a__Type.`Time`, interval (1) year) > now());
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent
|
||||||
|
//WHERE (date_add(a__Type__Parent.`Time2`, interval (1) year) > now())
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Subtract()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.Subtract(DateTime.Now).TotalSeconds > 0).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Time.Subtract(DateTime.Now).TotalSeconds > 0).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Parent.Time2.Subtract(DateTime.Now).TotalSeconds > 0).ToList());
|
||||||
|
//SELECT a."ID", a."CLICKS", a."TYPEGUID", a."TITLE", a."CREATETIME"
|
||||||
|
//FROM "TB_TOPIC111333" a
|
||||||
|
//WHERE ((extract(day from (systimestamp-a."CREATETIME"))*86400+extract(hour from (systimestamp-a."CREATETIME"))*3600+extract(minute from (systimestamp-a."CREATETIME"))*60+extract(second from (systimestamp-a."CREATETIME"))) > 0)
|
||||||
|
|
||||||
|
//SELECT a."ID", a."CLICKS", a."TYPEGUID", a__Type."GUID", a__Type."PARENTID", a__Type."NAME", a__Type."TIME", a."TITLE", a."CREATETIME"
|
||||||
|
//FROM "TB_TOPIC111333" a
|
||||||
|
//LEFT JOIN "TESTTYPEINFO333" a__Type ON a__Type."GUID" = a."TYPEGUID"
|
||||||
|
//WHERE ((extract(day from (systimestamp-a__Type."TIME"))*86400+extract(hour from (systimestamp-a__Type."TIME"))*3600+extract(minute from (systimestamp-a__Type."TIME"))*60+extract(second from (systimestamp-a__Type."TIME"))) > 0)
|
||||||
|
|
||||||
|
//SELECT a."ID", a."CLICKS", a."TYPEGUID", a__Type."GUID", a__Type."PARENTID", a__Type."NAME", a__Type."TIME", a."TITLE", a."CREATETIME"
|
||||||
|
//FROM "TB_TOPIC111333" a
|
||||||
|
//LEFT JOIN "TESTTYPEINFO333" a__Type ON a__Type."GUID" = a."TYPEGUID"
|
||||||
|
//LEFT JOIN "TESTTYPEPARENTINF1" a__Type__Parent ON a__Type__Parent."ID" = a__Type."PARENTID"
|
||||||
|
//WHERE ((extract(day from (systimestamp-a__Type__Parent."TIME2"))*86400+extract(hour from (systimestamp-a__Type__Parent."TIME2"))*3600+extract(minute from (systimestamp-a__Type__Parent."TIME2"))*60+extract(second from (systimestamp-a__Type__Parent."TIME2"))) > 0)
|
||||||
|
data.Add(select.Where(a => a.CreateTime.Subtract(TimeSpan.FromDays(1)) > a.CreateTime).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Time.Subtract(TimeSpan.FromDays(1)) > a.CreateTime).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Parent.Time2.Subtract(TimeSpan.FromDays(1)) > a.CreateTime).ToList());
|
||||||
|
//SELECT a."ID", a."CLICKS", a."TYPEGUID", a."TITLE", a."CREATETIME"
|
||||||
|
//FROM "TB_TOPIC111333" a
|
||||||
|
//WHERE ((a."CREATETIME"-numtodsinterval((1)*86400,'second')) > a."CREATETIME")
|
||||||
|
//SELECT a."ID", a."CLICKS", a."TYPEGUID", a__Type."GUID", a__Type."PARENTID", a__Type."NAME", a__Type."TIME", a."TITLE", a."CREATETIME"
|
||||||
|
|
||||||
|
//FROM "TB_TOPIC111333" a
|
||||||
|
//LEFT JOIN "TESTTYPEINFO333" a__Type ON a__Type."GUID" = a."TYPEGUID"
|
||||||
|
//WHERE ((a__Type."TIME"-numtodsinterval((1)*86400,'second')) > a."CREATETIME")
|
||||||
|
//SELECT a."ID", a."CLICKS", a."TYPEGUID", a__Type."GUID", a__Type."PARENTID", a__Type."NAME", a__Type."TIME", a."TITLE", a."CREATETIME"
|
||||||
|
|
||||||
|
//FROM "TB_TOPIC111333" a
|
||||||
|
//LEFT JOIN "TESTTYPEINFO333" a__Type ON a__Type."GUID" = a."TYPEGUID"
|
||||||
|
//LEFT JOIN "TESTTYPEPARENTINF1" a__Type__Parent ON a__Type__Parent."ID" = a__Type."PARENTID"
|
||||||
|
//WHERE ((a__Type__Parent."TIME2"-numtodsinterval((1)*86400,'second')) > a."CREATETIME")
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void 两个日期相减_效果同Subtract()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => (a.CreateTime - DateTime.Now).TotalSeconds > 0).ToList());
|
||||||
|
data.Add(select.Where(a => (a.Type.Time - DateTime.Now).TotalSeconds > 0).ToList());
|
||||||
|
data.Add(select.Where(a => (a.Type.Parent.Time2 - DateTime.Now).TotalSeconds > 0).ToList());
|
||||||
|
//SELECT a."ID", a."CLICKS", a."TYPEGUID", a."TITLE", a."CREATETIME"
|
||||||
|
//FROM "TB_TOPIC111333" a
|
||||||
|
//WHERE ((extract(day from (systimestamp-a."CREATETIME"))*86400+extract(hour from (systimestamp-a."CREATETIME"))*3600+extract(minute from (systimestamp-a."CREATETIME"))*60+extract(second from (systimestamp-a."CREATETIME"))) > 0)
|
||||||
|
|
||||||
|
//SELECT a."ID", a."CLICKS", a."TYPEGUID", a__Type."GUID", a__Type."PARENTID", a__Type."NAME", a__Type."TIME", a."TITLE", a."CREATETIME"
|
||||||
|
//FROM "TB_TOPIC111333" a
|
||||||
|
//LEFT JOIN "TESTTYPEINFO333" a__Type ON a__Type."GUID" = a."TYPEGUID"
|
||||||
|
//WHERE ((extract(day from (systimestamp-a__Type."TIME"))*86400+extract(hour from (systimestamp-a__Type."TIME"))*3600+extract(minute from (systimestamp-a__Type."TIME"))*60+extract(second from (systimestamp-a__Type."TIME"))) > 0)
|
||||||
|
|
||||||
|
//SELECT a."ID", a."CLICKS", a."TYPEGUID", a__Type."GUID", a__Type."PARENTID", a__Type."NAME", a__Type."TIME", a."TITLE", a."CREATETIME"
|
||||||
|
//FROM "TB_TOPIC111333" a
|
||||||
|
//LEFT JOIN "TESTTYPEINFO333" a__Type ON a__Type."GUID" = a."TYPEGUID"
|
||||||
|
//LEFT JOIN "TESTTYPEPARENTINF1" a__Type__Parent ON a__Type__Parent."ID" = a__Type."PARENTID"
|
||||||
|
//WHERE ((extract(day from (systimestamp-a__Type__Parent."TIME2"))*86400+extract(hour from (systimestamp-a__Type__Parent."TIME2"))*3600+extract(minute from (systimestamp-a__Type__Parent."TIME2"))*60+extract(second from (systimestamp-a__Type__Parent."TIME2"))) > 0)
|
||||||
|
data.Add(select.Where(a => (a.CreateTime - TimeSpan.FromDays(1)) > a.CreateTime).ToList());
|
||||||
|
data.Add(select.Where(a => (a.Type.Time - TimeSpan.FromDays(1)) > a.CreateTime).ToList());
|
||||||
|
data.Add(select.Where(a => (a.Type.Parent.Time2 - TimeSpan.FromDays(1)) > a.CreateTime).ToList());
|
||||||
|
//SELECT a."ID", a."CLICKS", a."TYPEGUID", a."TITLE", a."CREATETIME"
|
||||||
|
//FROM "TB_TOPIC111333" a
|
||||||
|
//WHERE ((a."CREATETIME"-numtodsinterval((1)*86400,'second')) > a."CREATETIME")
|
||||||
|
//SELECT a."ID", a."CLICKS", a."TYPEGUID", a__Type."GUID", a__Type."PARENTID", a__Type."NAME", a__Type."TIME", a."TITLE", a."CREATETIME"
|
||||||
|
|
||||||
|
//FROM "TB_TOPIC111333" a
|
||||||
|
//LEFT JOIN "TESTTYPEINFO333" a__Type ON a__Type."GUID" = a."TYPEGUID"
|
||||||
|
//WHERE ((a__Type."TIME"-numtodsinterval((1)*86400,'second')) > a."CREATETIME")
|
||||||
|
//SELECT a."ID", a."CLICKS", a."TYPEGUID", a__Type."GUID", a__Type."PARENTID", a__Type."NAME", a__Type."TIME", a."TITLE", a."CREATETIME"
|
||||||
|
|
||||||
|
//FROM "TB_TOPIC111333" a
|
||||||
|
//LEFT JOIN "TESTTYPEINFO333" a__Type ON a__Type."GUID" = a."TYPEGUID"
|
||||||
|
//LEFT JOIN "TESTTYPEPARENTINF1" a__Type__Parent ON a__Type__Parent."ID" = a__Type."PARENTID"
|
||||||
|
//WHERE ((a__Type__Parent."TIME2"-numtodsinterval((1)*86400,'second')) > a."CREATETIME")
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void this_Equals()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.AddYears(1).Equals(DateTime.Now)).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Time.AddYears(1).Equals(DateTime.Now)).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Parent.Time2.AddYears(1).Equals(DateTime.Now)).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic111333` a
|
||||||
|
//WHERE ((date_add(a.`CreateTime`, interval (1) year) = now()));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type
|
||||||
|
//WHERE ((date_add(a__Type.`Time`, interval (1) year) = now()));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent
|
||||||
|
//WHERE ((date_add(a__Type__Parent.`Time2`, interval (1) year) = now()))
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void DateTime_Compare()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.CompareTo(DateTime.Now) == 0).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Time.AddYears(1).CompareTo(DateTime.Now) == 0).ToList());
|
||||||
|
data.Add(select.Where(a => a.Type.Parent.Time2.AddYears(1).CompareTo(DateTime.Now) == 0).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic111333` a
|
||||||
|
//WHERE (((a.`CreateTime`) - (now())) = 0);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type
|
||||||
|
//WHERE (((date_add(a__Type.`Time`, interval (1) year)) - (now())) = 0);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent
|
||||||
|
//WHERE (((date_add(a__Type__Parent.`Time2`, interval (1) year)) - (now())) = 0)
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void DateTime_DaysInMonth()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => DateTime.DaysInMonth(a.CreateTime.Year, a.CreateTime.Month) > 30).ToList());
|
||||||
|
//data.Add(select.Where(a => DateTime.DaysInMonth(a.Type.Time.Year, a.Type.Time.Month) > 30).ToList());
|
||||||
|
//data.Add(select.Where(a => DateTime.DaysInMonth(a.Type.Parent.Time2.Year, a.Type.Parent.Time2.Month) > 30).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic111333` a
|
||||||
|
//WHERE (dayofmonth(last_day(concat(year(a.`CreateTime`), month(a.`CreateTime`), '-01'))) > 30);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type
|
||||||
|
//WHERE (dayofmonth(last_day(concat(year(a__Type.`Time`), month(a__Type.`Time`), '-01'))) > 30);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent
|
||||||
|
//WHERE (dayofmonth(last_day(concat(year(a__Type__Parent.`Time2`), month(a__Type__Parent.`Time2`), '-01'))) > 30)
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void DateTime_Equals()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => DateTime.Equals(a.CreateTime.AddYears(1), DateTime.Now)).ToList());
|
||||||
|
data.Add(select.Where(a => DateTime.Equals(a.Type.Time.AddYears(1), DateTime.Now)).ToList());
|
||||||
|
data.Add(select.Where(a => DateTime.Equals(a.Type.Parent.Time2.AddYears(1), DateTime.Now)).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic111333` a
|
||||||
|
//WHERE ((date_add(a.`CreateTime`, interval (1) year) = now()));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type
|
||||||
|
//WHERE ((date_add(a__Type.`Time`, interval (1) year) = now()));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent
|
||||||
|
//WHERE ((date_add(a__Type__Parent.`Time2`, interval (1) year) = now()))
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void DateTime_IsLeapYear()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => DateTime.IsLeapYear(a.CreateTime.Year)).ToList());
|
||||||
|
data.Add(select.Where(a => DateTime.IsLeapYear(a.Type.Time.AddYears(1).Year)).ToList());
|
||||||
|
data.Add(select.Where(a => DateTime.IsLeapYear(a.Type.Parent.Time2.AddYears(1).Year)).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic111333` a
|
||||||
|
//WHERE (((year(a.`CreateTime`)) % 4 = 0 AND (year(a.`CreateTime`)) % 100 <> 0 OR (year(a.`CreateTime`)) % 400 = 0));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type
|
||||||
|
//WHERE (((year(date_add(a__Type.`Time`, interval (1) year))) % 4 = 0 AND (year(date_add(a__Type.`Time`, interval (1) year))) % 100 <> 0 OR (year(date_add(a__Type.`Time`, interval (1) year))) % 400 = 0));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent
|
||||||
|
//WHERE (((year(date_add(a__Type__Parent.`Time2`, interval (1) year))) % 4 = 0 AND (year(date_add(a__Type__Parent.`Time2`, interval (1) year))) % 100 <> 0 OR (year(date_add(a__Type__Parent.`Time2`, interval (1) year))) % 400 = 0))
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void DateTime_Parse()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => DateTime.Parse(a.CreateTime.ToString()) > DateTime.Now).ToList());
|
||||||
|
data.Add(select.Where(a => DateTime.Parse(a.Type.Time.AddYears(1).ToString()) > DateTime.Now).ToList());
|
||||||
|
data.Add(select.Where(a => DateTime.Parse(a.Type.Parent.Time2.AddYears(1).ToString()) > DateTime.Now).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic111333` a
|
||||||
|
//WHERE (cast(date_format(a.`CreateTime`, '%Y-%m-%d %H:%i:%s.%f') as datetime) > now());
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type
|
||||||
|
//WHERE (cast(date_format(date_add(a__Type.`Time`, interval (1) year), '%Y-%m-%d %H:%i:%s.%f') as datetime) > now());
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||||
|
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent
|
||||||
|
//WHERE (cast(date_format(date_add(a__Type__Parent.`Time2`, interval (1) year), '%Y-%m-%d %H:%i:%s.%f') as datetime) > now())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,156 @@
|
|||||||
|
using FreeSql.DataAnnotations;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace FreeSql.Tests.OracleOledbExpression
|
||||||
|
{
|
||||||
|
public class MathTest
|
||||||
|
{
|
||||||
|
|
||||||
|
ISelect<Topic> select => g.oracle.Select<Topic>();
|
||||||
|
|
||||||
|
[Table(Name = "tb_topic")]
|
||||||
|
class Topic
|
||||||
|
{
|
||||||
|
[Column(IsIdentity = true, IsPrimary = true)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int Clicks { get; set; }
|
||||||
|
public int TypeGuid { get; set; }
|
||||||
|
public TestTypeInfo Type { get; set; }
|
||||||
|
public string Title { get; set; }
|
||||||
|
public DateTime CreateTime { get; set; }
|
||||||
|
}
|
||||||
|
class TestTypeInfo
|
||||||
|
{
|
||||||
|
public int Guid { get; set; }
|
||||||
|
public int ParentId { get; set; }
|
||||||
|
public TestTypeParentInfo Parent { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
}
|
||||||
|
class TestTypeParentInfo
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
public List<TestTypeInfo> Types { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void PI()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => Math.PI + a.Clicks > 0).ToList());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Abs()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => Math.Abs(-a.Clicks) > 0).ToList());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Sign()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => Math.Sign(-a.Clicks) > 0).ToList());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Floor()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => Math.Floor(a.Clicks + 0.5) == a.Clicks).ToList());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Ceiling()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => Math.Ceiling(a.Clicks + 0.5) == a.Clicks + 1).ToList());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Round()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => Math.Round(a.Clicks + 0.5) == a.Clicks).ToList());
|
||||||
|
data.Add(select.Where(a => Math.Round(a.Clicks + 0.5, 1) > a.Clicks).ToList());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Exp()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => Math.Exp(1) == a.Clicks + 1).ToList());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Log()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => Math.Log(a.Clicks + 0.5) == a.Clicks + 1).ToList());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Log10()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => Math.Log10(a.Clicks + 0.5) == a.Clicks + 1).ToList());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Pow()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => Math.Pow(2, a.Clicks % 5) == a.Clicks + 1).ToList());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Sqrt()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => Math.Sqrt(Math.Pow(2, a.Clicks % 5)) == a.Clicks + 1).ToList());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Cos()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => Math.Cos(Math.Pow(2, a.Clicks % 5)) == a.Clicks + 1).ToList());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Sin()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => Math.Sin(Math.Pow(2, a.Clicks % 5)) == a.Clicks + 1).ToList());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Tan()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => Math.Tan(Math.Pow(2, a.Clicks % 5)) == a.Clicks + 1).ToList());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Acos()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
//data.Add(select.Where(a => Math.Acos(Math.Pow(2, a.Clicks % 5)) == a.Clicks + 1).ToList());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Asin()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
//data.Add(select.Where(a => Math.Asin(Math.Pow(2, a.Clicks % 5)) == a.Clicks + 1).ToList());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Atan()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => Math.Atan(Math.Pow(2, a.Clicks % 5)) == a.Clicks + 1).ToList());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Atan2()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
//data.Add(select.Where(a => Math.Atan2(2, a.Clicks) == a.Clicks + 1).ToList());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Truncate()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => Math.Truncate(a.Clicks * 1.0 / 3) == a.Clicks + 1).ToList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,165 @@
|
|||||||
|
using FreeSql.DataAnnotations;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace FreeSql.Tests.OracleOledbExpression
|
||||||
|
{
|
||||||
|
public class OtherTest
|
||||||
|
{
|
||||||
|
|
||||||
|
ISelect<TableAllType> select => g.oracle.Select<TableAllType>();
|
||||||
|
|
||||||
|
public OtherTest()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Div()
|
||||||
|
{
|
||||||
|
var t1 = select.Where(a => a.Int / 3 > 3).Limit(10).ToList();
|
||||||
|
var t2 = select.Where(a => a.Long / 3 > 3).Limit(10).ToList();
|
||||||
|
var t3 = select.Where(a => a.Short / 3 > 3).Limit(10).ToList();
|
||||||
|
|
||||||
|
var t4 = select.Where(a => a.Int / 3.0 > 3).Limit(10).ToList();
|
||||||
|
var t5 = select.Where(a => a.Long / 3.0 > 3).Limit(10).ToList();
|
||||||
|
var t6 = select.Where(a => a.Short / 3.0 > 3).Limit(10).ToList();
|
||||||
|
|
||||||
|
var t7 = select.Where(a => a.Double / 3 > 3).Limit(10).ToList();
|
||||||
|
var t8 = select.Where(a => a.Decimal / 3 > 3).Limit(10).ToList();
|
||||||
|
var t9 = select.Where(a => a.Float / 3 > 3).Limit(10).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Boolean()
|
||||||
|
{
|
||||||
|
var t1 = select.Where(a => a.Bool == true).ToList();
|
||||||
|
var t2 = select.Where(a => a.Bool != true).ToList();
|
||||||
|
var t3 = select.Where(a => a.Bool == false).ToList();
|
||||||
|
var t4 = select.Where(a => !a.Bool).ToList();
|
||||||
|
var t5 = select.Where(a => a.Bool).ToList();
|
||||||
|
var t51 = select.WhereCascade(a => a.Bool).ToList();
|
||||||
|
|
||||||
|
var t11 = select.Where(a => a.BoolNullable == true).ToList();
|
||||||
|
var t22 = select.Where(a => a.BoolNullable != true).ToList();
|
||||||
|
var t33 = select.Where(a => a.BoolNullable == false).ToList();
|
||||||
|
var t44 = select.Where(a => !a.BoolNullable.Value).ToList();
|
||||||
|
var t55 = select.Where(a => a.BoolNullable.Value).ToList();
|
||||||
|
|
||||||
|
var t111 = select.Where(a => a.Bool == true && a.Id > 0).ToList();
|
||||||
|
var t222 = select.Where(a => a.Bool != true && a.Id > 0).ToList();
|
||||||
|
var t333 = select.Where(a => a.Bool == false && a.Id > 0).ToList();
|
||||||
|
var t444 = select.Where(a => !a.Bool && a.Id > 0).ToList();
|
||||||
|
var t555 = select.Where(a => a.Bool && a.Id > 0).ToList();
|
||||||
|
|
||||||
|
var t1111 = select.Where(a => a.BoolNullable == true && a.Id > 0).ToList();
|
||||||
|
var t2222 = select.Where(a => a.BoolNullable != true && a.Id > 0).ToList();
|
||||||
|
var t3333 = select.Where(a => a.BoolNullable == false && a.Id > 0).ToList();
|
||||||
|
var t4444 = select.Where(a => !a.BoolNullable.Value && a.Id > 0).ToList();
|
||||||
|
var t5555 = select.Where(a => a.BoolNullable.Value && a.Id > 0).ToList();
|
||||||
|
|
||||||
|
var t11111 = select.Where(a => a.Bool == true && a.Id > 0 && a.Bool == true).ToList();
|
||||||
|
var t22222 = select.Where(a => a.Bool != true && a.Id > 0 && a.Bool != true).ToList();
|
||||||
|
var t33333 = select.Where(a => a.Bool == false && a.Id > 0 && a.Bool == false).ToList();
|
||||||
|
var t44444 = select.Where(a => !a.Bool && a.Id > 0 && !a.Bool).ToList();
|
||||||
|
var t55555 = select.Where(a => a.Bool && a.Id > 0 && a.Bool).ToList();
|
||||||
|
|
||||||
|
var t111111 = select.Where(a => a.BoolNullable == true && a.Id > 0 && a.BoolNullable == true).ToList();
|
||||||
|
var t222222 = select.Where(a => a.BoolNullable != true && a.Id > 0 && a.BoolNullable != true).ToList();
|
||||||
|
var t333333 = select.Where(a => a.BoolNullable == false && a.Id > 0 && a.BoolNullable == false).ToList();
|
||||||
|
var t444444 = select.Where(a => !a.BoolNullable.Value && a.Id > 0 && !a.BoolNullable.Value).ToList();
|
||||||
|
var t555555 = select.Where(a => a.BoolNullable.Value && a.Id > 0 && a.BoolNullable.Value).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Array()
|
||||||
|
{
|
||||||
|
IEnumerable<int> testlinqlist = new List<int>(new[] { 1, 2, 3 });
|
||||||
|
var testlinq = select.Where(a => testlinqlist.Contains(a.Int)).ToList();
|
||||||
|
|
||||||
|
//in not in
|
||||||
|
var sql111 = select.Where(a => new[] { 1, 2, 3 }.Contains(a.Int)).ToList();
|
||||||
|
//var sql112 = select.Where(a => new[] { 1, 2, 3 }.Contains(a.Int) == false).ToList();
|
||||||
|
var sql113 = select.Where(a => !new[] { 1, 2, 3 }.Contains(a.Int)).ToList();
|
||||||
|
|
||||||
|
var inarray = new[] { 1, 2, 3 };
|
||||||
|
var sql1111 = select.Where(a => inarray.Contains(a.Int)).ToList();
|
||||||
|
//var sql1122 = select.Where(a => inarray.Contains(a.Int) == false).ToList();
|
||||||
|
var sql1133 = select.Where(a => !inarray.Contains(a.Int)).ToList();
|
||||||
|
|
||||||
|
|
||||||
|
//in not in
|
||||||
|
var sql11111 = select.Where(a => new List<int>() { 1, 2, 3 }.Contains(a.Int)).ToList();
|
||||||
|
//var sql11222 = select.Where(a => new List<int>() { 1, 2, 3 }.Contains(a.Int) == false).ToList();
|
||||||
|
var sql11333 = select.Where(a => !new List<int>() { 1, 2, 3 }.Contains(a.Int)).ToList();
|
||||||
|
|
||||||
|
var sql11111a = select.Where(a => new List<int>(new[] { 1, 2, 3 }).Contains(a.Int)).ToList();
|
||||||
|
//var sql11222b = select.Where(a => new List<int>(new[] { 1, 2, 3 }).Contains(a.Int) == false).ToList();
|
||||||
|
var sql11333c = select.Where(a => !new List<int>(new[] { 1, 2, 3 }).Contains(a.Int)).ToList();
|
||||||
|
|
||||||
|
var inarray2 = new List<int>() { 1, 2, 3 };
|
||||||
|
var sql111111 = select.Where(a => inarray.Contains(a.Int)).ToList();
|
||||||
|
//var sql112222 = select.Where(a => inarray.Contains(a.Int) == false).ToList();
|
||||||
|
var sql113333 = select.Where(a => !inarray.Contains(a.Int)).ToList();
|
||||||
|
|
||||||
|
var inarray2n = Enumerable.Range(1, 3333).ToArray();
|
||||||
|
var sql1111111 = select.Where(a => inarray2n.Contains(a.Int)).ToList();
|
||||||
|
var sql1122222 = select.Where(a => inarray2n.Contains(a.Int) == false).ToList();
|
||||||
|
var sql1133333 = select.Where(a => !inarray2n.Contains(a.Int)).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Table(Name = "tb_alltype")]
|
||||||
|
class TableAllType
|
||||||
|
{
|
||||||
|
[Column(IsIdentity = true, IsPrimary = true)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public string id2 { get; set; } = "id2=10";
|
||||||
|
|
||||||
|
public bool Bool { get; set; }
|
||||||
|
public sbyte SByte { get; set; }
|
||||||
|
public short Short { get; set; }
|
||||||
|
public int Int { get; set; }
|
||||||
|
public long Long { get; set; }
|
||||||
|
public byte Byte { get; set; }
|
||||||
|
public ushort UShort { get; set; }
|
||||||
|
public uint UInt { get; set; }
|
||||||
|
public ulong ULong { get; set; }
|
||||||
|
public double Double { get; set; }
|
||||||
|
public float Float { get; set; }
|
||||||
|
public decimal Decimal { get; set; }
|
||||||
|
public TimeSpan TimeSpan { get; set; }
|
||||||
|
public DateTime DateTime { get; set; }
|
||||||
|
public DateTime DateTimeOffSet { get; set; }
|
||||||
|
public byte[] Bytes { get; set; }
|
||||||
|
public string String { get; set; }
|
||||||
|
public Guid Guid { get; set; }
|
||||||
|
|
||||||
|
public bool? BoolNullable { get; set; }
|
||||||
|
public sbyte? SByteNullable { get; set; }
|
||||||
|
public short? ShortNullable { get; set; }
|
||||||
|
public int? IntNullable { get; set; }
|
||||||
|
public long? testFielLongNullable { get; set; }
|
||||||
|
public byte? ByteNullable { get; set; }
|
||||||
|
public ushort? UShortNullable { get; set; }
|
||||||
|
public uint? UIntNullable { get; set; }
|
||||||
|
public ulong? ULongNullable { get; set; }
|
||||||
|
public double? DoubleNullable { get; set; }
|
||||||
|
public float? FloatNullable { get; set; }
|
||||||
|
public decimal? DecimalNullable { get; set; }
|
||||||
|
public TimeSpan? TimeSpanNullable { get; set; }
|
||||||
|
public DateTime? DateTimeNullable { get; set; }
|
||||||
|
public DateTime? DateTimeOffSetNullable { get; set; }
|
||||||
|
public Guid? GuidNullable { get; set; }
|
||||||
|
|
||||||
|
public TableAllTypeEnumType1 Enum1 { get; set; }
|
||||||
|
public TableAllTypeEnumType1? Enum1Nullable { get; set; }
|
||||||
|
public TableAllTypeEnumType2 Enum2 { get; set; }
|
||||||
|
public TableAllTypeEnumType2? Enum2Nullable { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum TableAllTypeEnumType1 { e1, e2, e3, e5 }
|
||||||
|
[Flags] public enum TableAllTypeEnumType2 { f1, f2, f3 }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,827 @@
|
|||||||
|
using FreeSql.DataAnnotations;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace FreeSql.Tests.OracleOledbExpression
|
||||||
|
{
|
||||||
|
public class StringTest
|
||||||
|
{
|
||||||
|
|
||||||
|
ISelect<Topic> select => g.oracle.Select<Topic>();
|
||||||
|
|
||||||
|
[Table(Name = "tb_topic")]
|
||||||
|
class Topic
|
||||||
|
{
|
||||||
|
[Column(IsIdentity = true, IsPrimary = true)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int Clicks { get; set; }
|
||||||
|
public int TypeGuid { get; set; }
|
||||||
|
public TestTypeInfo Type { get; set; }
|
||||||
|
public string Title { get; set; }
|
||||||
|
public DateTime CreateTime { get; set; }
|
||||||
|
}
|
||||||
|
class TestTypeInfo
|
||||||
|
{
|
||||||
|
[Column(IsIdentity = true)]
|
||||||
|
public int Guid { get; set; }
|
||||||
|
public int ParentId { get; set; }
|
||||||
|
public TestTypeParentInfo Parent { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
}
|
||||||
|
class TestTypeParentInfo
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
public List<TestTypeInfo> Types { get; set; }
|
||||||
|
}
|
||||||
|
class TestEqualsGuid
|
||||||
|
{
|
||||||
|
public Guid id { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Equals__()
|
||||||
|
{
|
||||||
|
var list = new List<object>();
|
||||||
|
list.Add(select.Where(a => a.Title.Equals("aaa")).ToList());
|
||||||
|
list.Add(g.oracle.Select<TestEqualsGuid>().Where(a => a.id.Equals(Guid.Empty)).ToList());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void StringJoin()
|
||||||
|
{
|
||||||
|
var fsql = g.oracle;
|
||||||
|
fsql.Delete<StringJoin01>().Where("1=1").ExecuteAffrows();
|
||||||
|
fsql.Insert(new[] { new StringJoin01 { name = "北京" }, new StringJoin01 { name = "上海" }, new StringJoin01 { name = "深圳" }, }).ExecuteAffrows();
|
||||||
|
|
||||||
|
var val1 = string.Join(",", fsql.Select<StringJoin01>().ToList(a => a.name));
|
||||||
|
var val2 = fsql.Select<StringJoin01>().ToList(a => string.Join(",", fsql.Select<StringJoin01>().As("b").ToList(b => b.name)));
|
||||||
|
Assert.Equal(val1, val2[0]);
|
||||||
|
|
||||||
|
val1 = string.Join("**", fsql.Select<StringJoin01>().ToList(a => a.name));
|
||||||
|
val2 = fsql.Select<StringJoin01>().ToList(a => string.Join("**", fsql.Select<StringJoin01>().As("b").ToList(b => b.name)));
|
||||||
|
Assert.Equal(val1, val2[0]);
|
||||||
|
|
||||||
|
val1 = string.Join(",", fsql.Select<StringJoin01>().ToList(a => a.id));
|
||||||
|
val2 = fsql.Select<StringJoin01>().ToList(a => string.Join(",", fsql.Select<StringJoin01>().As("b").ToList(b => b.id)));
|
||||||
|
Assert.Equal(val1, val2[0]);
|
||||||
|
|
||||||
|
val1 = string.Join("**", fsql.Select<StringJoin01>().ToList(a => a.id));
|
||||||
|
val2 = fsql.Select<StringJoin01>().ToList(a => string.Join("**", fsql.Select<StringJoin01>().As("b").ToList(b => b.id)));
|
||||||
|
Assert.Equal(val1, val2[0]);
|
||||||
|
}
|
||||||
|
class StringJoin01
|
||||||
|
{
|
||||||
|
[Column(IsIdentity = true)]
|
||||||
|
public int id { get; set; }
|
||||||
|
public string name { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void First()
|
||||||
|
{
|
||||||
|
Assert.Equal('x', select.First(a => "x1".First()));
|
||||||
|
Assert.Equal('z', select.First(a => "z1".First()));
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void FirstOrDefault()
|
||||||
|
{
|
||||||
|
Assert.Equal('x', select.First(a => "x1".FirstOrDefault()));
|
||||||
|
Assert.Equal('z', select.First(a => "z1".FirstOrDefault()));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Format()
|
||||||
|
{
|
||||||
|
var item = g.oracle.GetRepository<Topic>().Insert(new Topic { Clicks = 101, Title = "我是中国人101", CreateTime = DateTime.Parse("2020-7-5") });
|
||||||
|
var sql = select.WhereDynamic(item).ToSql(a => new
|
||||||
|
{
|
||||||
|
str = $"x{a.Id + 1}z-{a.CreateTime.ToString("yyyyMM")}{a.Title}",
|
||||||
|
str2 = string.Format("{0}x{0}z-{1}{2}", a.Id + 1, a.CreateTime.ToString("yyyyMM"), a.Title)
|
||||||
|
});
|
||||||
|
Assert.Equal($@"SELECT 'x'||nvl((a.""ID"" + 1), '')||'z-'||nvl(to_char(a.""CREATETIME"",'YYYYMM'), '')||''||nvl(a.""TITLE"", '')||'' as1, ''||nvl((a.""ID"" + 1), '')||'x'||nvl((a.""ID"" + 1), '')||'z-'||nvl(to_char(a.""CREATETIME"",'YYYYMM'), '')||''||nvl(a.""TITLE"", '')||'' as2
|
||||||
|
FROM ""TB_TOPIC"" a
|
||||||
|
WHERE (a.""ID"" = {item.Id})", sql);
|
||||||
|
|
||||||
|
var item2 = select.WhereDynamic(item).First(a => new
|
||||||
|
{
|
||||||
|
str = $"x{a.Id + 1}z-{a.CreateTime.ToString("yyyyMM")}{a.Title}",
|
||||||
|
str2 = string.Format("{0}x{0}z-{1}{2}", a.Id + 1, a.CreateTime.ToString("yyyyMM"), a.Title)
|
||||||
|
});
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal($"x{item.Id + 1}z-{item.CreateTime.ToString("yyyyMM")}{item.Title}", item2.str);
|
||||||
|
Assert.Equal(string.Format("{0}x{0}z-{1}{2}", item.Id + 1, item.CreateTime.ToString("yyyyMM"), item.Title), item2.str2);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Format4()
|
||||||
|
{
|
||||||
|
//3个 {} 时,Arguments 解析出来是分开的
|
||||||
|
//4个 {} 时,Arguments[1] 只能解析这个出来,然后里面是 NewArray []
|
||||||
|
var item = g.oracle.GetRepository<Topic>().Insert(new Topic { Clicks = 101, Title = "我是中国人101", CreateTime = DateTime.Parse("2020-7-5") });
|
||||||
|
var sql = select.WhereDynamic(item).ToSql(a => new
|
||||||
|
{
|
||||||
|
str = $"x{a.Id + 1}z-{a.CreateTime.ToString("yyyyMM")}{a.Title}{a.Title}",
|
||||||
|
str2 = string.Format("{0}x{0}z-{1}{2}{3}", a.Id + 1, a.CreateTime.ToString("yyyyMM"), a.Title, a.Title)
|
||||||
|
});
|
||||||
|
Assert.Equal($@"SELECT 'x'||nvl((a.""ID"" + 1), '')||'z-'||nvl(to_char(a.""CREATETIME"",'YYYYMM'), '')||''||nvl(a.""TITLE"", '')||''||nvl(a.""TITLE"", '')||'' as1, ''||nvl((a.""ID"" + 1), '')||'x'||nvl((a.""ID"" + 1), '')||'z-'||nvl(to_char(a.""CREATETIME"",'YYYYMM'), '')||''||nvl(a.""TITLE"", '')||''||nvl(a.""TITLE"", '')||'' as2
|
||||||
|
FROM ""TB_TOPIC"" a
|
||||||
|
WHERE (a.""ID"" = {item.Id})", sql);
|
||||||
|
|
||||||
|
var item2 = select.WhereDynamic(item).First(a => new
|
||||||
|
{
|
||||||
|
str = $"x{a.Id + 1}z-{a.CreateTime.ToString("yyyyMM")}{a.Title}{a.Title}",
|
||||||
|
str2 = string.Format("{0}x{0}z-{1}{2}{3}", a.Id + 1, a.CreateTime.ToString("yyyyMM"), a.Title, a.Title)
|
||||||
|
});
|
||||||
|
Assert.NotNull(item2);
|
||||||
|
Assert.Equal($"x{item.Id + 1}z-{item.CreateTime.ToString("yyyyMM")}{item.Title}{item.Title}", item2.str);
|
||||||
|
Assert.Equal(string.Format("{0}x{0}z-{1}{2}{3}", item.Id + 1, item.CreateTime.ToString("yyyyMM"), item.Title, item.Title), item2.str2);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Empty()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => (a.Title ?? "") == string.Empty).ToSql());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (ifnull(a.`Title`, '') = '')
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void StartsWith()
|
||||||
|
{
|
||||||
|
var list = new List<object>();
|
||||||
|
list.Add(select.Where(a => a.Title.StartsWith("aaa")).ToList());
|
||||||
|
list.Add(select.Where(a => a.Title.StartsWith(a.Title)).ToList());
|
||||||
|
list.Add(select.Where(a => a.Title.StartsWith(a.Title + 1)).ToList());
|
||||||
|
list.Add(select.Where(a => a.Title.StartsWith(a.Type.Name)).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE((a.`Title`) LIKE '%aaa')
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE((a.`Title`) LIKE concat('%', a.`Title`))
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE((a.`Title`) LIKE concat('%', concat(a.`Title`, 1)))
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8
|
||||||
|
//FROM `tb_topic` a, `TestTypeInfo` a__Type
|
||||||
|
//WHERE((a.`Title`) LIKE concat('%', a__Type.`Name`))
|
||||||
|
list.Add(select.Where(a => (a.Title + "aaa").StartsWith("aaa")).ToList());
|
||||||
|
list.Add(select.Where(a => (a.Title + "aaa").StartsWith(a.Title)).ToList());
|
||||||
|
list.Add(select.Where(a => (a.Title + "aaa").StartsWith(a.Title + 1)).ToList());
|
||||||
|
list.Add(select.Where(a => (a.Title + "aaa").StartsWith(a.Type.Name)).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE((concat(a.`Title`, 'aaa')) LIKE '%aaa')
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE((concat(a.`Title`, 'aaa')) LIKE concat('%', a.`Title`))
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE((concat(a.`Title`, 'aaa')) LIKE concat('%', concat(a.`Title`, 1)))
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8
|
||||||
|
//FROM `tb_topic` a, `TestTypeInfo` a__Type
|
||||||
|
//WHERE((concat(a.`Title`, 'aaa')) LIKE concat('%', a__Type.`Name`))
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void EndsWith()
|
||||||
|
{
|
||||||
|
var list = new List<object>();
|
||||||
|
list.Add(select.Where(a => a.Title.EndsWith("aaa")).ToList());
|
||||||
|
list.Add(select.Where(a => a.Title.EndsWith(a.Title)).ToList());
|
||||||
|
list.Add(select.Where(a => a.Title.EndsWith(a.Title + 1)).ToList());
|
||||||
|
list.Add(select.Where(a => a.Title.EndsWith(a.Type.Name)).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE((a.`Title`) LIKE 'aaa%')
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE((a.`Title`) LIKE concat(a.`Title`, '%'))
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE((a.`Title`) LIKE concat(concat(a.`Title`, 1), '%'))
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8
|
||||||
|
//FROM `tb_topic` a, `TestTypeInfo` a__Type
|
||||||
|
//WHERE((a.`Title`) LIKE concat(a__Type.`Name`, '%'))
|
||||||
|
list.Add(select.Where(a => (a.Title + "aaa").EndsWith("aaa")).ToList());
|
||||||
|
list.Add(select.Where(a => (a.Title + "aaa").EndsWith(a.Title)).ToList());
|
||||||
|
list.Add(select.Where(a => (a.Title + "aaa").EndsWith(a.Title + 1)).ToList());
|
||||||
|
list.Add(select.Where(a => (a.Title + "aaa").EndsWith(a.Type.Name)).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE((concat(a.`Title`, 'aaa')) LIKE 'aaa%')
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE((concat(a.`Title`, 'aaa')) LIKE concat(a.`Title`, '%'))
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE((concat(a.`Title`, 'aaa')) LIKE concat(concat(a.`Title`, 1), '%'))
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8
|
||||||
|
//FROM `tb_topic` a, `TestTypeInfo` a__Type
|
||||||
|
//WHERE((concat(a.`Title`, 'aaa')) LIKE concat(a__Type.`Name`, '%'))
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Contains()
|
||||||
|
{
|
||||||
|
var list = new List<object>();
|
||||||
|
list.Add(select.Where(a => a.Title.Contains("aaa")).ToList());
|
||||||
|
list.Add(select.Where(a => a.Title.Contains(a.Title)).ToList());
|
||||||
|
list.Add(select.Where(a => a.Title.Contains(a.Title + 1)).ToList());
|
||||||
|
list.Add(select.Where(a => a.Title.Contains(a.Type.Name)).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE((a.`Title`) LIKE '%aaa%')
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE((a.`Title`) LIKE concat('%', a.`Title`, '%'))
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE((a.`Title`) LIKE concat('%', a.`Title` +1, '%'))
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8
|
||||||
|
//FROM `tb_topic` a, `TestTypeInfo` a__Type
|
||||||
|
//WHERE((a.`Title`) LIKE concat('%', a__Type.`Name`, '%'))
|
||||||
|
list.Add(select.Where(a => (a.Title + "aaa").Contains("aaa")).ToList());
|
||||||
|
list.Add(select.Where(a => (a.Title + "aaa").Contains(a.Title)).ToList());
|
||||||
|
list.Add(select.Where(a => (a.Title + "aaa").Contains(a.Title + 1)).ToList());
|
||||||
|
list.Add(select.Where(a => (a.Title + "aaa").Contains(a.Type.Name)).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE((concat(a.`Title`, 'aaa')) LIKE '%aaa%')
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE((concat(a.`Title`, 'aaa')) LIKE concat('%', a.`Title`, '%'))
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE((concat(a.`Title`, 'aaa')) LIKE concat('%', concat(a.`Title`, 1), '%'))
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8
|
||||||
|
//FROM `tb_topic` a, `TestTypeInfo` a__Type
|
||||||
|
//WHERE((concat(a.`Title`, 'aaa')) LIKE concat('%', a__Type.`Name`, '%'))
|
||||||
|
|
||||||
|
|
||||||
|
list.Add(select.Where(a => a.Title.Contains("%")).ToList());
|
||||||
|
list.Add(select.Where(a => a.Title.Contains(a.Title + "%")).ToList());
|
||||||
|
list.Add(select.Where(a => a.Title.Contains(a.Title + 1 + "%")).ToList());
|
||||||
|
list.Add(select.Where(a => a.Title.Contains(a.Type.Name + "%")).ToList());
|
||||||
|
|
||||||
|
list.Add(select.Where(a => (a.Title + "aaa").Contains("aaa" + "%")).ToList());
|
||||||
|
list.Add(select.Where(a => (a.Title + "aaa").Contains(a.Title + "%")).ToList());
|
||||||
|
list.Add(select.Where(a => (a.Title + "aaa").Contains(a.Title + 1 + "%")).ToList());
|
||||||
|
list.Add(select.Where(a => (a.Title + "aaa").Contains(a.Type.Name + "%")).ToList());
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void ToLower()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.Title.ToLower() == "aaa").ToList());
|
||||||
|
data.Add(select.Where(a => a.Title.ToLower() == a.Title).ToList());
|
||||||
|
data.Add(select.Where(a => a.Title.ToLower() == (a.Title + 1)).ToList());
|
||||||
|
data.Add(select.Where(a => a.Title.ToLower() == a.Type.Name).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE(lower(a.`Title`) = 'aaa');
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE(lower(a.`Title`) = a.`Title`);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE(lower(a.`Title`) = concat(a.`Title`, 1));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8
|
||||||
|
//FROM `tb_topic` a, `TestTypeInfo` a__Type
|
||||||
|
//WHERE(lower(a.`Title`) = a__Type.`Name`);
|
||||||
|
data.Add(select.Where(a => (a.Title.ToLower() + "aaa").ToLower() == "aaa").ToList());
|
||||||
|
data.Add(select.Where(a => (a.Title.ToLower() + "aaa").ToLower() == a.Title).ToList());
|
||||||
|
data.Add(select.Where(a => (a.Title.ToLower() + "aaa").ToLower() == (a.Title + 1)).ToList());
|
||||||
|
data.Add(select.Where(a => (a.Title.ToLower() + "aaa").ToLower() == a.Type.Name).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE(lower(concat(lower(a.`Title`), 'aaa')) = 'aaa');
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE(lower(concat(lower(a.`Title`), 'aaa')) = a.`Title`);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE(lower(concat(lower(a.`Title`), 'aaa')) = concat(a.`Title`, 1));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8
|
||||||
|
//FROM `tb_topic` a, `TestTypeInfo` a__Type
|
||||||
|
//WHERE(lower(concat(lower(a.`Title`), 'aaa')) = a__Type.`Name`)
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void ToUpper()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.Title.ToUpper() == "aaa").ToList());
|
||||||
|
data.Add(select.Where(a => a.Title.ToUpper() == a.Title).ToList());
|
||||||
|
data.Add(select.Where(a => a.Title.ToUpper() == (a.Title + 1)).ToList());
|
||||||
|
data.Add(select.Where(a => a.Title.ToUpper() == a.Type.Name).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (upper(a.`Title`) = 'aaa');
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (upper(a.`Title`) = a.`Title`);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (upper(a.`Title`) = concat(a.`Title`, 1));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8
|
||||||
|
//FROM `tb_topic` a, `TestTypeInfo` a__Type
|
||||||
|
//WHERE (upper(a.`Title`) = a__Type.`Name`);
|
||||||
|
data.Add(select.Where(a => (a.Title.ToUpper() + "aaa").ToUpper() == "aaa").ToList());
|
||||||
|
data.Add(select.Where(a => (a.Title.ToUpper() + "aaa").ToUpper() == a.Title).ToList());
|
||||||
|
data.Add(select.Where(a => (a.Title.ToUpper() + "aaa").ToUpper() == (a.Title + 1)).ToList());
|
||||||
|
data.Add(select.Where(a => (a.Title.ToUpper() + "aaa").ToUpper() == a.Type.Name).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (upper(concat(upper(a.`Title`), 'aaa')) = 'aaa');
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (upper(concat(upper(a.`Title`), 'aaa')) = a.`Title`);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (upper(concat(upper(a.`Title`), 'aaa')) = concat(a.`Title`, 1));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8
|
||||||
|
//FROM `tb_topic` a, `TestTypeInfo` a__Type
|
||||||
|
//WHERE (upper(concat(upper(a.`Title`), 'aaa')) = a__Type.`Name`)
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Substring()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.Title.Substring(0) == "aaa").ToList());
|
||||||
|
data.Add(select.Where(a => a.Title.Substring(0) == a.Title).ToList());
|
||||||
|
data.Add(select.Where(a => a.Title.Substring(0) == (a.Title + 1)).ToList());
|
||||||
|
data.Add(select.Where(a => a.Title.Substring(0) == a.Type.Name).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (substr(a.`Title`, 1) = 'aaa');
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (substr(a.`Title`, 1) = a.`Title`);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (substr(a.`Title`, 1) = concat(a.`Title`, 1));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8
|
||||||
|
//FROM `tb_topic` a, `TestTypeInfo` a__Type
|
||||||
|
//WHERE (substr(a.`Title`, 1) = a__Type.`Name`);
|
||||||
|
data.Add(select.Where(a => (a.Title.Substring(0) + "aaa").Substring(a.Title.Length) == "aaa").ToList());
|
||||||
|
data.Add(select.Where(a => (a.Title.Substring(0) + "aaa").Substring(0, a.Title.Length) == a.Title).ToList());
|
||||||
|
data.Add(select.Where(a => (a.Title.Substring(0) + "aaa").Substring(0, 3) == (a.Title + 1)).ToList());
|
||||||
|
data.Add(select.Where(a => (a.Title.Substring(0) + "aaa").Substring(1, 2) == a.Type.Name).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (substr(concat(substr(a.`Title`, 1), 'aaa'), char_length(a.`Title`) + 1) = 'aaa');
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (substr(concat(substr(a.`Title`, 1), 'aaa'), 1, char_length(a.`Title`)) = a.`Title`);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (substr(concat(substr(a.`Title`, 1), 'aaa'), 1, 3) = concat(a.`Title`, 1));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8
|
||||||
|
//FROM `tb_topic` a, `TestTypeInfo` a__Type
|
||||||
|
//WHERE (substr(concat(substr(a.`Title`, 1), 'aaa'), 2, 2) = a__Type.`Name`)
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Length()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.Title.Length == 0).ToList());
|
||||||
|
data.Add(select.Where(a => a.Title.Length == 1).ToList());
|
||||||
|
data.Add(select.Where(a => a.Title.Length == a.Title.Length + 1).ToList());
|
||||||
|
data.Add(select.Where(a => a.Title.Length == a.Type.Name.Length).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (char_length(a.`Title`) = 0);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (char_length(a.`Title`) = 1);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (char_length(a.`Title`) = char_length(a.`Title`) + 1);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8
|
||||||
|
//FROM `tb_topic` a, `TestTypeInfo` a__Type
|
||||||
|
//WHERE (char_length(a.`Title`) = char_length(a__Type.`Name`));
|
||||||
|
data.Add(select.Where(a => (a.Title + "aaa").Length == 0).ToList());
|
||||||
|
data.Add(select.Where(a => (a.Title + "aaa").Length == 1).ToList());
|
||||||
|
data.Add(select.Where(a => (a.Title + "aaa").Length == a.Title.Length + 1).ToList());
|
||||||
|
data.Add(select.Where(a => (a.Title + "aaa").Length == a.Type.Name.Length).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (char_length(concat(a.`Title`, 'aaa')) = 0);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (char_length(concat(a.`Title`, 'aaa')) = 1);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (char_length(concat(a.`Title`, 'aaa')) = char_length(a.`Title`) + 1);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8
|
||||||
|
//FROM `tb_topic` a, `TestTypeInfo` a__Type
|
||||||
|
//WHERE (char_length(concat(a.`Title`, 'aaa')) = char_length(a__Type.`Name`))
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void IndexOf()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.Title.IndexOf("aaa") == -1).ToList());
|
||||||
|
data.Add(select.Where(a => a.Title.IndexOf("aaa", 2) == -1).ToList());
|
||||||
|
data.Add(select.Where(a => a.Title.IndexOf("aaa", 2) == (a.Title.Length + 1)).ToList());
|
||||||
|
data.Add(select.Where(a => a.Title.IndexOf("aaa", 2) == a.Type.Name.Length + 1).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE ((locate(a.`Title`, 'aaa') - 1) = -1);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE ((locate(a.`Title`, 'aaa', 3) - 1) = -1);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE ((locate(a.`Title`, 'aaa', 3) - 1) = char_length(a.`Title`) + 1);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8
|
||||||
|
//FROM `tb_topic` a, `TestTypeInfo` a__Type
|
||||||
|
//WHERE ((locate(a.`Title`, 'aaa', 3) - 1) = char_length(a__Type.`Name`) + 1);
|
||||||
|
data.Add(select.Where(a => (a.Title + "aaa").IndexOf("aaa") == -1).ToList());
|
||||||
|
data.Add(select.Where(a => (a.Title + "aaa").IndexOf("aaa", 2) == -1).ToList());
|
||||||
|
data.Add(select.Where(a => (a.Title + "aaa").IndexOf("aaa", 2) == (a.Title.Length + 1)).ToList());
|
||||||
|
data.Add(select.Where(a => (a.Title + "aaa").IndexOf("aaa", 2) == a.Type.Name.Length + 1).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE ((locate(concat(a.`Title`, 'aaa'), 'aaa') - 1) = -1);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE ((locate(concat(a.`Title`, 'aaa'), 'aaa', 3) - 1) = -1);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE ((locate(concat(a.`Title`, 'aaa'), 'aaa', 3) - 1) = char_length(a.`Title`) + 1);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8
|
||||||
|
//FROM `tb_topic` a, `TestTypeInfo` a__Type
|
||||||
|
//WHERE ((locate(concat(a.`Title`, 'aaa'), 'aaa', 3) - 1) = char_length(a__Type.`Name`) + 1)
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void PadLeft()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.Title.PadLeft(10, 'a') == "aaa").ToList());
|
||||||
|
data.Add(select.Where(a => a.Title.PadLeft(10, 'a') == a.Title).ToList());
|
||||||
|
data.Add(select.Where(a => a.Title.PadLeft(10, 'a') == (a.Title + 1)).ToList());
|
||||||
|
data.Add(select.Where(a => a.Title.PadLeft(10, 'a') == a.Type.Name).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (lpad(a.`Title`, 10, 'a') = 'aaa');
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (lpad(a.`Title`, 10, 'a') = a.`Title`);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (lpad(a.`Title`, 10, 'a') = concat(a.`Title`, 1));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8
|
||||||
|
//FROM `tb_topic` a, `TestTypeInfo` a__Type
|
||||||
|
//WHERE (lpad(a.`Title`, 10, 'a') = a__Type.`Name`);
|
||||||
|
data.Add(select.Where(a => (a.Title.PadLeft(10, 'a') + "aaa").PadLeft(20, 'b') == "aaa").ToList());
|
||||||
|
data.Add(select.Where(a => (a.Title.PadLeft(10, 'a') + "aaa").PadLeft(20, 'b') == a.Title).ToList());
|
||||||
|
data.Add(select.Where(a => (a.Title.PadLeft(10, 'a') + "aaa").PadLeft(20, 'b') == (a.Title + 1)).ToList());
|
||||||
|
data.Add(select.Where(a => (a.Title.PadLeft(10, 'a') + "aaa").PadLeft(20, 'b') == a.Type.Name).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (lpad(concat(lpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = 'aaa');
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (lpad(concat(lpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = a.`Title`);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (lpad(concat(lpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = concat(a.`Title`, 1));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8
|
||||||
|
//FROM `tb_topic` a, `TestTypeInfo` a__Type
|
||||||
|
//WHERE (lpad(concat(lpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = a__Type.`Name`)
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void PadRight()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.Title.PadRight(10, 'a') == "aaa").ToList());
|
||||||
|
data.Add(select.Where(a => a.Title.PadRight(10, 'a') == a.Title).ToList());
|
||||||
|
data.Add(select.Where(a => a.Title.PadRight(10, 'a') == (a.Title + 1)).ToList());
|
||||||
|
data.Add(select.Where(a => a.Title.PadRight(10, 'a') == a.Type.Name).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (rpad(a.`Title`, 10, 'a') = 'aaa');
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (rpad(a.`Title`, 10, 'a') = a.`Title`);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (rpad(a.`Title`, 10, 'a') = concat(a.`Title`, 1));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8
|
||||||
|
//FROM `tb_topic` a, `TestTypeInfo` a__Type
|
||||||
|
//WHERE (rpad(a.`Title`, 10, 'a') = a__Type.`Name`);
|
||||||
|
data.Add(select.Where(a => (a.Title.PadRight(10, 'a') + "aaa").PadRight(20, 'b') == "aaa").ToList());
|
||||||
|
data.Add(select.Where(a => (a.Title.PadRight(10, 'a') + "aaa").PadRight(20, 'b') == a.Title).ToList());
|
||||||
|
data.Add(select.Where(a => (a.Title.PadRight(10, 'a') + "aaa").PadRight(20, 'b') == (a.Title + 1)).ToList());
|
||||||
|
data.Add(select.Where(a => (a.Title.PadRight(10, 'a') + "aaa").PadRight(20, 'b') == a.Type.Name).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (rpad(concat(rpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = 'aaa');
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (rpad(concat(rpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = a.`Title`);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (rpad(concat(rpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = concat(a.`Title`, 1));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8
|
||||||
|
//FROM `tb_topic` a, `TestTypeInfo` a__Type
|
||||||
|
//WHERE (rpad(concat(rpad(a.`Title`, 10, 'a'), 'aaa'), 20, 'b') = a__Type.`Name`)
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Trim()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.Title.Trim() == "aaa").ToList());
|
||||||
|
data.Add(select.Where(a => a.Title.Trim('a') == a.Title).ToList());
|
||||||
|
data.Add(select.Where(a => a.Title.Trim('a', 'b') == (a.Title + 1)).ToList());
|
||||||
|
data.Add(select.Where(a => a.Title.Trim('a', 'b', 'c') == a.Type.Name).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (trim(a.`Title`) = 'aaa');
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (trim('a' from a.`Title`) = a.`Title`);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (trim('b' from trim('a' from a.`Title`)) = concat(a.`Title`, 1));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8
|
||||||
|
//FROM `tb_topic` a, `TestTypeInfo` a__Type
|
||||||
|
//WHERE (trim('c' from trim('b' from trim('a' from a.`Title`))) = a__Type.`Name`);
|
||||||
|
data.Add(select.Where(a => (a.Title.Trim() + "aaa").Trim() == "aaa").ToList());
|
||||||
|
data.Add(select.Where(a => (a.Title.Trim('a') + "aaa").Trim('a') == a.Title).ToList());
|
||||||
|
data.Add(select.Where(a => (a.Title.Trim('a', 'b') + "aaa").Trim('a', 'b') == (a.Title + 1)).ToList());
|
||||||
|
data.Add(select.Where(a => (a.Title.Trim('a', 'b', 'c') + "aaa").Trim('a', 'b', 'c') == a.Type.Name).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (trim(concat(trim(a.`Title`), 'aaa')) = 'aaa');
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (trim('a' from concat(trim('a' from a.`Title`), 'aaa')) = a.`Title`);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (trim('b' from trim('a' from concat(trim('b' from trim('a' from a.`Title`)), 'aaa'))) = concat(a.`Title`, 1));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8
|
||||||
|
//FROM `tb_topic` a, `TestTypeInfo` a__Type
|
||||||
|
//WHERE (trim('c' from trim('b' from trim('a' from concat(trim('c' from trim('b' from trim('a' from a.`Title`))), 'aaa')))) = a__Type.`Name`)
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void TrimStart()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.Title.TrimStart() == "aaa").ToList());
|
||||||
|
data.Add(select.Where(a => a.Title.TrimStart('a') == a.Title).ToList());
|
||||||
|
data.Add(select.Where(a => a.Title.TrimStart('a', 'b') == (a.Title + 1)).ToList());
|
||||||
|
data.Add(select.Where(a => a.Title.TrimStart('a', 'b', 'c') == a.Type.Name).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (ltrim(a.`Title`) = 'aaa');
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (trim(trailing 'a' from trim(leading 'a' from a.`Title`)) = a.`Title`);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (trim(trailing 'b' from trim(leading 'b' from trim(trailing 'a' from trim(leading 'a' from a.`Title`)))) = concat(a.`Title`, 1));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8
|
||||||
|
//FROM `tb_topic` a, `TestTypeInfo` a__Type
|
||||||
|
//WHERE (trim(trailing 'c' from trim(leading 'c' from trim(trailing 'b' from trim(leading 'b' from trim(trailing 'a' from trim(leading 'a' from a.`Title`)))))) = a__Type.`Name`);
|
||||||
|
data.Add(select.Where(a => (a.Title.TrimStart() + "aaa").TrimStart() == "aaa").ToList());
|
||||||
|
data.Add(select.Where(a => (a.Title.TrimStart('a') + "aaa").TrimStart('a') == a.Title).ToList());
|
||||||
|
data.Add(select.Where(a => (a.Title.TrimStart('a', 'b') + "aaa").TrimStart('a', 'b') == (a.Title + 1)).ToList());
|
||||||
|
data.Add(select.Where(a => (a.Title.TrimStart('a', 'b', 'c') + "aaa").TrimStart('a', 'b', 'c') == a.Type.Name).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (ltrim(concat(ltrim(a.`Title`), 'aaa')) = 'aaa');
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (trim(trailing 'a' from trim(leading 'a' from concat(trim(trailing 'a' from trim(leading 'a' from a.`Title`)), 'aaa'))) = a.`Title`);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (trim(trailing 'b' from trim(leading 'b' from trim(trailing 'a' from trim(leading 'a' from concat(trim(trailing 'b' from trim(leading 'b' from trim(trailing 'a' from trim(leading 'a' from a.`Title`)))), 'aaa'))))) = concat(a.`Title`, 1));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8
|
||||||
|
//FROM `tb_topic` a, `TestTypeInfo` a__Type
|
||||||
|
//WHERE (trim(trailing 'c' from trim(leading 'c' from trim(trailing 'b' from trim(leading 'b' from trim(trailing 'a' from trim(leading 'a' from concat(trim(trailing 'c' from trim(leading 'c' from trim(trailing 'b' from trim(leading 'b' from trim(trailing 'a' from trim(leading 'a' from a.`Title`)))))), 'aaa'))))))) = a__Type.`Name`)
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void TrimEnd()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.Title.TrimEnd() == "aaa").ToList());
|
||||||
|
data.Add(select.Where(a => a.Title.TrimEnd('a') == a.Title).ToList());
|
||||||
|
data.Add(select.Where(a => a.Title.TrimEnd('a', 'b') == (a.Title + 1)).ToList());
|
||||||
|
data.Add(select.Where(a => a.Title.TrimEnd('a', 'b', 'c') == a.Type.Name).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (rtrim(a.`Title`) = 'aaa');
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (trim(trailing 'a' from a.`Title`) = a.`Title`);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (trim(trailing 'b' from trim(trailing 'a' from a.`Title`)) = concat(a.`Title`, 1));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8
|
||||||
|
//FROM `tb_topic` a, `TestTypeInfo` a__Type
|
||||||
|
//WHERE (trim(trailing 'c' from trim(trailing 'b' from trim(trailing 'a' from a.`Title`))) = a__Type.`Name`);
|
||||||
|
data.Add(select.Where(a => (a.Title.TrimEnd() + "aaa").TrimEnd() == "aaa").ToList());
|
||||||
|
data.Add(select.Where(a => (a.Title.TrimEnd('a') + "aaa").TrimEnd('a') == a.Title).ToList());
|
||||||
|
data.Add(select.Where(a => (a.Title.TrimEnd('a', 'b') + "aaa").TrimEnd('a', 'b') == (a.Title + 1)).ToList());
|
||||||
|
data.Add(select.Where(a => (a.Title.TrimEnd('a', 'b', 'c') + "aaa").TrimEnd('a', 'b', 'c') == a.Type.Name).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (rtrim(concat(rtrim(a.`Title`), 'aaa')) = 'aaa');
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (trim(trailing 'a' from concat(trim(trailing 'a' from a.`Title`), 'aaa')) = a.`Title`);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (trim(trailing 'b' from trim(trailing 'a' from concat(trim(trailing 'b' from trim(trailing 'a' from a.`Title`)), 'aaa'))) = concat(a.`Title`, 1));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8
|
||||||
|
//FROM `tb_topic` a, `TestTypeInfo` a__Type
|
||||||
|
//WHERE (trim(trailing 'c' from trim(trailing 'b' from trim(trailing 'a' from concat(trim(trailing 'c' from trim(trailing 'b' from trim(trailing 'a' from a.`Title`))), 'aaa')))) = a__Type.`Name`)
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Replace()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.Title.Replace("a", "b") == "aaa").ToList());
|
||||||
|
data.Add(select.Where(a => a.Title.Replace("a", "b").Replace("b", "c") == a.Title).ToList());
|
||||||
|
data.Add(select.Where(a => a.Title.Replace("a", "b").Replace("b", "c").Replace("c", "a") == (a.Title + 1)).ToList());
|
||||||
|
data.Add(select.Where(a => a.Title.Replace("a", "b").Replace("b", "c").Replace(a.Type.Name, "a") == a.Type.Name).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (replace(a.`Title`, 'a', 'b') = 'aaa');
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (replace(replace(a.`Title`, 'a', 'b'), 'b', 'c') = a.`Title`);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (replace(replace(replace(a.`Title`, 'a', 'b'), 'b', 'c'), 'c', 'a') = concat(a.`Title`, 1));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8
|
||||||
|
//FROM `tb_topic` a, `TestTypeInfo` a__Type
|
||||||
|
//WHERE (replace(replace(replace(a.`Title`, 'a', 'b'), 'b', 'c'), a__Type.`Name`, 'a') = a__Type.`Name`);
|
||||||
|
data.Add(select.Where(a => (a.Title.Replace("a", "b") + "aaa").TrimEnd() == "aaa").ToList());
|
||||||
|
data.Add(select.Where(a => (a.Title.Replace("a", "b").Replace("b", "c") + "aaa").TrimEnd('a') == a.Title).ToList());
|
||||||
|
data.Add(select.Where(a => (a.Title.Replace("a", "b").Replace("b", "c").Replace("c", "a") + "aaa").TrimEnd('a', 'b') == (a.Title + 1)).ToList());
|
||||||
|
data.Add(select.Where(a => (a.Title.Replace("a", "b").Replace("b", "c").Replace(a.Type.Name, "a") + "aaa").TrimEnd('a', 'b', 'c') == a.Type.Name).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (concat(replace(a.`Title`, 'a', 'b'), 'aaa') = 'aaa');
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (concat(replace(replace(a.`Title`, 'a', 'b'), 'b', 'c'), 'aaa') = a.`Title`);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (concat(replace(replace(replace(a.`Title`, 'a', 'b'), 'b', 'c'), 'c', 'a'), 'aaa') = concat(a.`Title`, 1));
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8
|
||||||
|
//FROM `tb_topic` a, `TestTypeInfo` a__Type
|
||||||
|
//WHERE (concat(replace(replace(replace(a.`Title`, 'a', 'b'), 'b', 'c'), a__Type.`Name`, 'a'), 'aaa') = a__Type.`Name`)
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void CompareTo()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.Title.CompareTo(a.Title) == 0).ToList());
|
||||||
|
data.Add(select.Where(a => a.Title.CompareTo(a.Title) > 0).ToList());
|
||||||
|
data.Add(select.Where(a => a.Title.CompareTo(a.Title + 1) == 0).ToList());
|
||||||
|
data.Add(select.Where(a => a.Title.CompareTo(a.Title + a.Type.Name) == 0).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (strcmp(a.`Title`, a.`Title`) = 0);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (strcmp(a.`Title`, a.`Title`) > 0);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (strcmp(a.`Title`, concat(a.`Title`, 1)) = 0);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8
|
||||||
|
//FROM `tb_topic` a, `TestTypeInfo` a__Type
|
||||||
|
//WHERE (strcmp(a.`Title`, concat(a.`Title`, a__Type.`Name`)) = 0);
|
||||||
|
data.Add(select.Where(a => (a.Title + "aaa").CompareTo("aaa") == 0).ToList());
|
||||||
|
data.Add(select.Where(a => (a.Title + "aaa").CompareTo(a.Title) > 0).ToList());
|
||||||
|
data.Add(select.Where(a => (a.Title + "aaa").CompareTo(a.Title + 1) == 0).ToList());
|
||||||
|
data.Add(select.Where(a => (a.Title + "aaa").CompareTo(a.Type.Name) == 0).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (strcmp(concat(a.`Title`, 'aaa'), 'aaa') = 0);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (strcmp(concat(a.`Title`, 'aaa'), a.`Title`) > 0);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (strcmp(concat(a.`Title`, 'aaa'), concat(a.`Title`, 1)) = 0);
|
||||||
|
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8
|
||||||
|
//FROM `tb_topic` a, `TestTypeInfo` a__Type
|
||||||
|
//WHERE (strcmp(concat(a.`Title`, 'aaa'), a__Type.`Name`) = 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void string_IsNullOrEmpty()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => string.IsNullOrEmpty(a.Title)).ToList());
|
||||||
|
data.Add(select.Where(a => !string.IsNullOrEmpty(a.Title)).ToList());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void string_IsNullOrWhiteSpace()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => string.IsNullOrWhiteSpace(a.Title)).ToList());
|
||||||
|
data.Add(select.Where(a => !string.IsNullOrWhiteSpace(a.Title)).ToList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,293 @@
|
|||||||
|
using FreeSql.DataAnnotations;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace FreeSql.Tests.OracleOledbExpression
|
||||||
|
{
|
||||||
|
public class TimeSpanTest
|
||||||
|
{
|
||||||
|
|
||||||
|
ISelect<Topic> select => g.oracle.Select<Topic>();
|
||||||
|
|
||||||
|
[Table(Name = "tb_topic")]
|
||||||
|
class Topic
|
||||||
|
{
|
||||||
|
[Column(IsIdentity = true, IsPrimary = true)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int Clicks { get; set; }
|
||||||
|
public int TypeGuid { get; set; }
|
||||||
|
public TestTypeInfo Type { get; set; }
|
||||||
|
public string Title { get; set; }
|
||||||
|
public DateTime CreateTime { get; set; }
|
||||||
|
}
|
||||||
|
class TestTypeInfo
|
||||||
|
{
|
||||||
|
public int Guid { get; set; }
|
||||||
|
public int ParentId { get; set; }
|
||||||
|
public TestTypeParentInfo Parent { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
}
|
||||||
|
class TestTypeParentInfo
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
public List<TestTypeInfo> Types { get; set; }
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Zero()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.TimeOfDay > TimeSpan.Zero).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) > 0)
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void MinValue()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.TimeOfDay > TimeSpan.MinValue).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) > -922337203685477580)
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void MaxValue()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.TimeOfDay < TimeSpan.MaxValue).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) < 922337203685477580)
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Days()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.TimeOfDay.Days == 0).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) div 86400000000) = 0)
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Hours()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.TimeOfDay.Hours > 0).ToSql());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) div 3600000000) mod 24 > 0)
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Milliseconds()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.TimeOfDay.Milliseconds > 0).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) div 1000 mod 1000) > 0)
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Minutes()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.TimeOfDay.Minutes > 0).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) div 60000000 mod 60) > 0)
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Seconds()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.TimeOfDay.Seconds > 0).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) div 1000000 mod 60) > 0)
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Ticks()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.TimeOfDay.Ticks > 0).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) * 10) > 0)
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void TotalDays()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.TimeOfDay.TotalDays > 0).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) / 86400000000) > 0)
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void TotalHours()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.TimeOfDay.TotalHours > 0).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) / 3600000000) > 0)
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void TotalMilliseconds()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.TimeOfDay.TotalMilliseconds > 0).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) / 1000) > 0)
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void TotalMinutes()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.TimeOfDay.TotalMinutes > 0).ToSql());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) / 60000000) > 0)
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void TotalSeconds()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.TimeOfDay.TotalSeconds > 0).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) / 1000000) > 0)
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Add()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.TimeOfDay.Add(TimeSpan.FromDays(1)) > TimeSpan.Zero).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) + (1 * 86400000000)) > 0)
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void Subtract()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.TimeOfDay.Subtract(TimeSpan.FromDays(1)) > TimeSpan.Zero).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) - (1 * 86400000000)) > 0)
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void CompareTo()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.TimeOfDay.CompareTo(TimeSpan.FromDays(1)) > 0).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) - ((1 * 86400000000))) > 0)
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void this_Equals()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.TimeOfDay.Equals(TimeSpan.FromDays(1))).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 86400000000)))
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void this_ToString()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => a.CreateTime.TimeOfDay.ToString() == "ssss").ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (date_format(date_add(cast('0001/1/1 0:00:00' as datetime), interval (timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) microsecond), '%Y-%m-%d %H:%i:%s.%f') = 'ssss')
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void TimeSpan_Compare()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => TimeSpan.Compare(a.CreateTime.TimeOfDay, TimeSpan.FromDays(1)) > 0).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) - ((1 * 86400000000))) > 0)
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void TimeSpan_Equals()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromDays(1))).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 86400000000)))
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void TimeSpan_FromDays()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromDays(1))).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 86400000000)))
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void TimeSpan_FromHours()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromHours(1))).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 3600000000)))
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void TimeSpan_FromMilliseconds()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromMilliseconds(1))).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 1000)))
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void TimeSpan_FromMinutes()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromMinutes(1))).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 60000000)))
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void TimeSpan_FromSeconds()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromSeconds(1))).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 * 1000000)))
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void TimeSpan_FromTicks()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => TimeSpan.Equals(a.CreateTime.TimeOfDay, TimeSpan.FromTicks(1))).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE ((timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000) = (1 / 10)))
|
||||||
|
}
|
||||||
|
[Fact]
|
||||||
|
public void TimeSpan_Parse()
|
||||||
|
{
|
||||||
|
var data = new List<object>();
|
||||||
|
data.Add(select.Where(a => TimeSpan.Parse(a.CreateTime.TimeOfDay.ToString()) > TimeSpan.Zero).ToList());
|
||||||
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||||
|
//FROM `tb_topic` a
|
||||||
|
//WHERE (cast(date_format(date_add(cast('0001/1/1 0:00:00' as datetime), interval (timestampdiff(microsecond, date_format(a.`CreateTime`, '1970-1-1 %H:%i:%s.%f'), a.`CreateTime`) + 62135596800000000)) microsecond), '%Y-%m-%d %H:%i:%s.%f') as signed) > 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
26
FreeSql.Tests/FreeSql.Tests.Provider.OracleOledb/g.cs
Normal file
26
FreeSql.Tests/FreeSql.Tests.Provider.OracleOledb/g.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
|
public class g
|
||||||
|
{
|
||||||
|
|
||||||
|
static Lazy<IFreeSql> oracleLazy = new Lazy<IFreeSql>(() => new FreeSql.FreeSqlBuilder()
|
||||||
|
.UseConnectionString(FreeSql.DataType.Oracle, "Provider=OraOLEDB.Oracle;user id=9user;password=123456;data source=//127.0.0.1:1521/XE;Pooling=true;Max Pool Size=2")
|
||||||
|
.UseAutoSyncStructure(true)
|
||||||
|
//.UseGenerateCommandParameterWithLambda(true)
|
||||||
|
.UseLazyLoading(true)
|
||||||
|
.UseNameConvert(FreeSql.Internal.NameConvertType.ToUpper)
|
||||||
|
//.UseNoneCommandParameter(true)
|
||||||
|
|
||||||
|
.UseMonitorCommand(
|
||||||
|
cmd => Trace.WriteLine("\r\n线程" + Thread.CurrentThread.ManagedThreadId + ": " + cmd.CommandText) //监听SQL命令对象,在执行前
|
||||||
|
//, (cmd, traceLog) => Console.WriteLine(traceLog)
|
||||||
|
)
|
||||||
|
.Build());
|
||||||
|
public static IFreeSql oracle => oracleLazy.Value;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1373,7 +1373,7 @@ FROM ( SELECT max(a.`Id`) `TaskId`, max(a.`Type`) `TaskType`, a.`ProcessId`, a.`
|
|||||||
WHERE (a.`IsFinished` = 1 AND (a.`AuditorId` = '1' OR a.`AuditorId` = '1cb71584-a6dd-4b26-8c88-ed9fb8cf87a3'))
|
WHERE (a.`IsFinished` = 1 AND (a.`AuditorId` = '1' OR a.`AuditorId` = '1cb71584-a6dd-4b26-8c88-ed9fb8cf87a3'))
|
||||||
GROUP BY a.`ProcessId`, a.`NodeId`, a.`NodeName` ) a
|
GROUP BY a.`ProcessId`, a.`NodeId`, a.`NodeName` ) a
|
||||||
LEFT JOIN `WF_ProcessInstance` b ON b.`Id` = a.`ProcessId`
|
LEFT JOIN `WF_ProcessInstance` b ON b.`Id` = a.`ProcessId`
|
||||||
WHERE ((b.`IsFinished` OR a.`TaskType` = 3) AND b.`EnabledMark` = 1)", groupsql12);
|
WHERE ((b.`IsFinished` = 1 OR a.`TaskType` = 3) AND b.`EnabledMark` = 1)", groupsql12);
|
||||||
|
|
||||||
var grouplist12 = g.mysql.Select<WF_TaskGroupBy, WF_ProcessInstance>()
|
var grouplist12 = g.mysql.Select<WF_TaskGroupBy, WF_ProcessInstance>()
|
||||||
.AsTable((type, old) => type == typeof(WF_TaskGroupBy) ? $"( {sqltmp12} )" : null)
|
.AsTable((type, old) => type == typeof(WF_TaskGroupBy) ? $"( {sqltmp12} )" : null)
|
||||||
|
33
FreeSql.sln
33
FreeSql.sln
@ -111,6 +111,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeSql.Tests.Provider.Sqli
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeSql.Provider.SqliteCore", "Providers\FreeSql.Provider.SqliteCore\FreeSql.Provider.SqliteCore.csproj", "{D4FEE5C1-6805-4B46-B10B-BE5CC942B883}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeSql.Provider.SqliteCore", "Providers\FreeSql.Provider.SqliteCore\FreeSql.Provider.SqliteCore.csproj", "{D4FEE5C1-6805-4B46-B10B-BE5CC942B883}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeSql.Provider.OracleOledb", "Providers\FreeSql.Provider.OracleOledb\FreeSql.Provider.OracleOledb.csproj", "{ECF7FC70-A7FC-4FC3-9BF7-462EA0A65F9C}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeSql.Tests.Provider.OracleOledb", "FreeSql.Tests\FreeSql.Tests.Provider.OracleOledb\FreeSql.Tests.Provider.OracleOledb.csproj", "{1DA3FF04-AA2C-4374-9368-68931D8D5B09}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -649,6 +653,30 @@ Global
|
|||||||
{D4FEE5C1-6805-4B46-B10B-BE5CC942B883}.Release|x64.Build.0 = Release|Any CPU
|
{D4FEE5C1-6805-4B46-B10B-BE5CC942B883}.Release|x64.Build.0 = Release|Any CPU
|
||||||
{D4FEE5C1-6805-4B46-B10B-BE5CC942B883}.Release|x86.ActiveCfg = Release|Any CPU
|
{D4FEE5C1-6805-4B46-B10B-BE5CC942B883}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{D4FEE5C1-6805-4B46-B10B-BE5CC942B883}.Release|x86.Build.0 = Release|Any CPU
|
{D4FEE5C1-6805-4B46-B10B-BE5CC942B883}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{ECF7FC70-A7FC-4FC3-9BF7-462EA0A65F9C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{ECF7FC70-A7FC-4FC3-9BF7-462EA0A65F9C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{ECF7FC70-A7FC-4FC3-9BF7-462EA0A65F9C}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{ECF7FC70-A7FC-4FC3-9BF7-462EA0A65F9C}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{ECF7FC70-A7FC-4FC3-9BF7-462EA0A65F9C}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{ECF7FC70-A7FC-4FC3-9BF7-462EA0A65F9C}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{ECF7FC70-A7FC-4FC3-9BF7-462EA0A65F9C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{ECF7FC70-A7FC-4FC3-9BF7-462EA0A65F9C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{ECF7FC70-A7FC-4FC3-9BF7-462EA0A65F9C}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{ECF7FC70-A7FC-4FC3-9BF7-462EA0A65F9C}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{ECF7FC70-A7FC-4FC3-9BF7-462EA0A65F9C}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{ECF7FC70-A7FC-4FC3-9BF7-462EA0A65F9C}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{1DA3FF04-AA2C-4374-9368-68931D8D5B09}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{1DA3FF04-AA2C-4374-9368-68931D8D5B09}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{1DA3FF04-AA2C-4374-9368-68931D8D5B09}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{1DA3FF04-AA2C-4374-9368-68931D8D5B09}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{1DA3FF04-AA2C-4374-9368-68931D8D5B09}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{1DA3FF04-AA2C-4374-9368-68931D8D5B09}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{1DA3FF04-AA2C-4374-9368-68931D8D5B09}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{1DA3FF04-AA2C-4374-9368-68931D8D5B09}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{1DA3FF04-AA2C-4374-9368-68931D8D5B09}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{1DA3FF04-AA2C-4374-9368-68931D8D5B09}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{1DA3FF04-AA2C-4374-9368-68931D8D5B09}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{1DA3FF04-AA2C-4374-9368-68931D8D5B09}.Release|x86.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@ -685,10 +713,11 @@ Global
|
|||||||
{86C56235-5D37-4422-807B-B31681C7D01C} = {2A381C57-2697-427B-9F10-55DA11FD02E4}
|
{86C56235-5D37-4422-807B-B31681C7D01C} = {2A381C57-2697-427B-9F10-55DA11FD02E4}
|
||||||
{BDE8EDC6-2646-45E0-A921-39CD1538A8C5} = {2A381C57-2697-427B-9F10-55DA11FD02E4}
|
{BDE8EDC6-2646-45E0-A921-39CD1538A8C5} = {2A381C57-2697-427B-9F10-55DA11FD02E4}
|
||||||
{D4FEE5C1-6805-4B46-B10B-BE5CC942B883} = {2A381C57-2697-427B-9F10-55DA11FD02E4}
|
{D4FEE5C1-6805-4B46-B10B-BE5CC942B883} = {2A381C57-2697-427B-9F10-55DA11FD02E4}
|
||||||
|
{ECF7FC70-A7FC-4FC3-9BF7-462EA0A65F9C} = {2A381C57-2697-427B-9F10-55DA11FD02E4}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
RESX_NeutralResourcesLanguage = en-US
|
|
||||||
RESX_PrefixTranslations = True
|
|
||||||
SolutionGuid = {089687FD-5D25-40AB-BA8A-A10D1E137F98}
|
SolutionGuid = {089687FD-5D25-40AB-BA8A-A10D1E137F98}
|
||||||
|
RESX_PrefixTranslations = True
|
||||||
|
RESX_NeutralResourcesLanguage = en-US
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.666-preview20220823</Version>
|
<Version>3.2.666-preview20220824</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -713,11 +713,6 @@
|
|||||||
天津南大通用数据技术股份有限公司成立于2004年,是国产数据库、大数据领域的知名企业,基于 Odbc 的实现
|
天津南大通用数据技术股份有限公司成立于2004年,是国产数据库、大数据领域的知名企业,基于 Odbc 的实现
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="F:FreeSql.DataType.OracleOledb">
|
|
||||||
<summary>
|
|
||||||
基于 OleDb 实现访问 Oracle 数据库,解决 US7ASCII 中文乱码问题 https://blog.csdn.net/guhun_shmily/article/details/83064225
|
|
||||||
</summary>
|
|
||||||
</member>
|
|
||||||
<member name="M:FreeSql.AdoNetExtensions.GetIFreeSql(System.Data.IDbConnection)">
|
<member name="M:FreeSql.AdoNetExtensions.GetIFreeSql(System.Data.IDbConnection)">
|
||||||
<summary>
|
<summary>
|
||||||
获取 IDbConnection 对应的 IFreeSql 实例
|
获取 IDbConnection 对应的 IFreeSql 实例
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
<SignAssembly>False</SignAssembly>
|
<SignAssembly>False</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.666-preview20220823</Version>
|
<Version>3.2.666-preview20220824</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.666-preview20220823</Version>
|
<Version>3.2.666-preview20220824</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
<Title>$(AssemblyName)</Title>
|
<Title>$(AssemblyName)</Title>
|
||||||
<IsPackable>true</IsPackable>
|
<IsPackable>true</IsPackable>
|
||||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||||
<Version>3.2.666-preview20220823</Version>
|
<Version>3.2.666-preview20220824</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.666-preview20220823</Version>
|
<Version>3.2.666-preview20220824</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.666-preview20220823</Version>
|
<Version>3.2.666-preview20220824</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
<Title>$(AssemblyName)</Title>
|
<Title>$(AssemblyName)</Title>
|
||||||
<IsPackable>true</IsPackable>
|
<IsPackable>true</IsPackable>
|
||||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||||
<Version>3.2.666-preview20220823</Version>
|
<Version>3.2.666-preview20220824</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.666-preview20220823</Version>
|
<Version>3.2.666-preview20220824</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.666-preview20220823</Version>
|
<Version>3.2.666-preview20220824</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.666-preview20220823</Version>
|
<Version>3.2.666-preview20220824</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.666-preview20220823</Version>
|
<Version>3.2.666-preview20220824</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.666-preview20220823</Version>
|
<Version>3.2.666-preview20220824</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -65,7 +65,7 @@ namespace FreeSql.Oracle
|
|||||||
#if oledb
|
#if oledb
|
||||||
new System.Data.OleDb.OleDbCommand();
|
new System.Data.OleDb.OleDbCommand();
|
||||||
#else
|
#else
|
||||||
new Oracle.ManagedDataAccess.Client.OracleCommand();
|
new global::Oracle.ManagedDataAccess.Client.OracleCommand();
|
||||||
cmd.BindByName = true;
|
cmd.BindByName = true;
|
||||||
#endif
|
#endif
|
||||||
return cmd;
|
return cmd;
|
||||||
|
@ -34,17 +34,17 @@ namespace FreeSql.Oracle
|
|||||||
{ typeof(int), CsToDb.New(OleDbType.Integer, "number", "number(11) NOT NULL", false, false, 0) },{ typeof(int?), CsToDb.New(OleDbType.Integer, "number", "number(11) NULL", false, true, null) },
|
{ typeof(int), CsToDb.New(OleDbType.Integer, "number", "number(11) NOT NULL", false, false, 0) },{ typeof(int?), CsToDb.New(OleDbType.Integer, "number", "number(11) NULL", false, true, null) },
|
||||||
{ typeof(long), CsToDb.New(OleDbType.BigInt, "number","number(21) NOT NULL", false, false, 0) },{ typeof(long?), CsToDb.New(OleDbType.BigInt, "number","number(21) NULL", false, true, null) },
|
{ typeof(long), CsToDb.New(OleDbType.BigInt, "number","number(21) NOT NULL", false, false, 0) },{ typeof(long?), CsToDb.New(OleDbType.BigInt, "number","number(21) NULL", false, true, null) },
|
||||||
|
|
||||||
{ typeof(byte), CsToDb.New(OleDbType.UnsignedTinyInt, "number","number(3) NOT NULL", true, false, 0) },{ typeof(byte?), CsToDb.New(OleDbType.UnsignedTinyInt, "number","number(3) NULL", true, true, null) },
|
{ typeof(byte), CsToDb.New(OleDbType.SmallInt, "number","number(3) NOT NULL", true, false, 0) },{ typeof(byte?), CsToDb.New(OleDbType.SmallInt, "number","number(3) NULL", true, true, null) },
|
||||||
{ typeof(ushort), CsToDb.New(OleDbType.UnsignedSmallInt, "number","number(5) NOT NULL", true, false, 0) },{ typeof(ushort?), CsToDb.New(OleDbType.UnsignedSmallInt, "number", "number(5) NULL", true, true, null) },
|
{ typeof(ushort), CsToDb.New(OleDbType.Decimal, "number","number(5) NOT NULL", true, false, 0) },{ typeof(ushort?), CsToDb.New(OleDbType.Decimal, "number", "number(5) NULL", true, true, null) },
|
||||||
{ typeof(uint), CsToDb.New(OleDbType.UnsignedInt, "number", "number(10) NOT NULL", true, false, 0) },{ typeof(uint?), CsToDb.New(OleDbType.UnsignedInt, "number", "number(10) NULL", true, true, null) },
|
{ typeof(uint), CsToDb.New(OleDbType.Decimal, "number", "number(10) NOT NULL", true, false, 0) },{ typeof(uint?), CsToDb.New(OleDbType.Decimal, "number", "number(10) NULL", true, true, null) },
|
||||||
{ typeof(ulong), CsToDb.New(OleDbType.UnsignedBigInt, "number", "number(20) NOT NULL", true, false, 0) },{ typeof(ulong?), CsToDb.New(OleDbType.UnsignedBigInt, "number", "number(20) NULL", true, true, null) },
|
{ typeof(ulong), CsToDb.New(OleDbType.Decimal, "number", "number(20) NOT NULL", true, false, 0) },{ typeof(ulong?), CsToDb.New(OleDbType.Decimal, "number", "number(20) NULL", true, true, null) },
|
||||||
|
|
||||||
{ typeof(double), CsToDb.New(OleDbType.Double, "float", "float(126) NOT NULL", false, false, 0) },{ typeof(double?), CsToDb.New(OleDbType.Double, "float", "float(126) NULL", false, true, null) },
|
{ typeof(double), CsToDb.New(OleDbType.Double, "float", "float(126) NOT NULL", false, false, 0) },{ typeof(double?), CsToDb.New(OleDbType.Double, "float", "float(126) NULL", false, true, null) },
|
||||||
{ typeof(float), CsToDb.New(OleDbType.Single, "float","float(63) NOT NULL", false, false, 0) },{ typeof(float?), CsToDb.New(OleDbType.Single, "float","float(63) NULL", false, true, null) },
|
{ typeof(float), CsToDb.New(OleDbType.Single, "float","float(63) NOT NULL", false, false, 0) },{ typeof(float?), CsToDb.New(OleDbType.Single, "float","float(63) NULL", false, true, null) },
|
||||||
{ typeof(decimal), CsToDb.New(OleDbType.Decimal, "number", "number(10,2) NOT NULL", false, false, 0) },{ typeof(decimal?), CsToDb.New(OleDbType.Decimal, "number", "number(10,2) NULL", false, true, null) },
|
{ typeof(decimal), CsToDb.New(OleDbType.Decimal, "number", "number(10,2) NOT NULL", false, false, 0) },{ typeof(decimal?), CsToDb.New(OleDbType.Decimal, "number", "number(10,2) NULL", false, true, null) },
|
||||||
|
|
||||||
{ typeof(TimeSpan), CsToDb.New(OleDbType.DBTime, "interval day to second","interval day(2) to second(6) NOT NULL", false, false, 0) },{ typeof(TimeSpan?), CsToDb.New(OleDbType.DBTime, "interval day to second", "interval day(2) to second(6) NULL",false, true, null) },
|
{ typeof(TimeSpan), CsToDb.New(OleDbType.DBTime, "interval day to second","interval day(2) to second(6) NOT NULL", false, false, 0) },{ typeof(TimeSpan?), CsToDb.New(OleDbType.DBTime, "interval day to second", "interval day(2) to second(6) NULL",false, true, null) },
|
||||||
{ typeof(DateTime), CsToDb.New(OleDbType.DBTime, "timestamp", "timestamp(6) NOT NULL", false, false, new DateTime(1970,1,1)) },{ typeof(DateTime?), CsToDb.New(OleDbType.DBTime, "timestamp", "timestamp(6) NULL", false, true, null) },
|
{ typeof(DateTime), CsToDb.New(OleDbType.DBTimeStamp, "timestamp", "timestamp(6) NOT NULL", false, false, new DateTime(1970,1,1)) },{ typeof(DateTime?), CsToDb.New(OleDbType.DBTimeStamp, "timestamp", "timestamp(6) NULL", false, true, null) },
|
||||||
{ typeof(DateTimeOffset), CsToDb.New(OleDbType.DBTimeStamp, "timestamp with local time zone", "timestamp(6) with local time zone NOT NULL", false, false, new DateTime(1970,1,1)) },{ typeof(DateTimeOffset?), CsToDb.New(OleDbType.DBTimeStamp, "timestamp with local time zone", "timestamp(6) with local time zone NULL", false, true, null) },
|
{ typeof(DateTimeOffset), CsToDb.New(OleDbType.DBTimeStamp, "timestamp with local time zone", "timestamp(6) with local time zone NOT NULL", false, false, new DateTime(1970,1,1)) },{ typeof(DateTimeOffset?), CsToDb.New(OleDbType.DBTimeStamp, "timestamp with local time zone", "timestamp(6) with local time zone NULL", false, true, null) },
|
||||||
|
|
||||||
{ typeof(byte[]), CsToDb.New(OleDbType.VarBinary, "blob", "blob NULL", false, null, new byte[0]) },
|
{ typeof(byte[]), CsToDb.New(OleDbType.VarBinary, "blob", "blob NULL", false, null, new byte[0]) },
|
||||||
|
@ -42,17 +42,17 @@ namespace FreeSql.Oracle
|
|||||||
case "number(11)": return OleDbType.Integer;
|
case "number(11)": return OleDbType.Integer;
|
||||||
case "number(21)": return OleDbType.BigInt;
|
case "number(21)": return OleDbType.BigInt;
|
||||||
|
|
||||||
case "number(3)": return OleDbType.UnsignedTinyInt;
|
case "number(3)": return OleDbType.TinyInt;
|
||||||
case "number(5)": return OleDbType.UnsignedSmallInt;
|
case "number(5)": return OleDbType.Decimal;
|
||||||
case "number(10)": return OleDbType.UnsignedInt;
|
case "number(10)": return OleDbType.Decimal;
|
||||||
case "number(20)": return OleDbType.UnsignedBigInt;
|
case "number(20)": return OleDbType.Decimal;
|
||||||
|
|
||||||
case "float(126)": return OleDbType.Double;
|
case "float(126)": return OleDbType.Double;
|
||||||
case "float(63)": return OleDbType.Single;
|
case "float(63)": return OleDbType.Single;
|
||||||
case "number(10,2)": return OleDbType.Decimal;
|
case "number(10,2)": return OleDbType.Decimal;
|
||||||
|
|
||||||
case "interval day(2) to second(6)": return OleDbType.DBTime;
|
case "interval day(2) to second(6)": return OleDbType.DBTime;
|
||||||
case "timestamp(6)": return OleDbType.DBTime;
|
case "timestamp(6)": return OleDbType.DBTimeStamp;
|
||||||
case "timestamp(6) with local time zone": return OleDbType.DBTimeStamp;
|
case "timestamp(6) with local time zone": return OleDbType.DBTimeStamp;
|
||||||
|
|
||||||
case "blob": return OleDbType.VarBinary;
|
case "blob": return OleDbType.VarBinary;
|
||||||
@ -73,10 +73,10 @@ namespace FreeSql.Oracle
|
|||||||
return OleDbType.DBTime;
|
return OleDbType.DBTime;
|
||||||
case "date":
|
case "date":
|
||||||
_dicDbToCs.TryAdd(dbfull, _dicDbToCs["date"]);
|
_dicDbToCs.TryAdd(dbfull, _dicDbToCs["date"]);
|
||||||
return OleDbType.DBTime;
|
return OleDbType.DBTimeStamp;
|
||||||
case "timestamp":
|
case "timestamp":
|
||||||
_dicDbToCs.TryAdd(dbfull, _dicDbToCs["timestamp(6)"]);
|
_dicDbToCs.TryAdd(dbfull, _dicDbToCs["timestamp(6)"]);
|
||||||
return OleDbType.DBTime;
|
return OleDbType.DBTimeStamp;
|
||||||
case "timestamp with local time zone":
|
case "timestamp with local time zone":
|
||||||
_dicDbToCs.TryAdd(dbfull, _dicDbToCs["timestamp(6) with local time zone"]);
|
_dicDbToCs.TryAdd(dbfull, _dicDbToCs["timestamp(6) with local time zone"]);
|
||||||
return OleDbType.DBTimeStamp;
|
return OleDbType.DBTimeStamp;
|
||||||
|
@ -2,7 +2,10 @@
|
|||||||
using FreeSql.Oracle.Curd;
|
using FreeSql.Oracle.Curd;
|
||||||
using System;
|
using System;
|
||||||
using System.Data.Common;
|
using System.Data.Common;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace FreeSql.Oracle
|
namespace FreeSql.Oracle
|
||||||
{
|
{
|
||||||
@ -25,7 +28,31 @@ namespace FreeSql.Oracle
|
|||||||
|
|
||||||
this.DbFirst = new OracleDbFirst(this, this.InternalCommonUtils, this.InternalCommonExpression);
|
this.DbFirst = new OracleDbFirst(this, this.InternalCommonUtils, this.InternalCommonExpression);
|
||||||
this.CodeFirst = new OracleCodeFirst(this, this.InternalCommonUtils, this.InternalCommonExpression);
|
this.CodeFirst = new OracleCodeFirst(this, this.InternalCommonUtils, this.InternalCommonExpression);
|
||||||
|
|
||||||
|
#if oledb
|
||||||
|
Select0Provider._dicMethodDataReaderGetValue[typeof(Guid)] = typeof(DbDataReader).GetMethod("GetGuid", new Type[] { typeof(int) });
|
||||||
|
Select0Provider._dicMethodDataReaderGetValue[typeof(bool)] = typeof(DbDataReader).GetMethod("GetBoolean", new Type[] { typeof(int) });
|
||||||
|
Select0Provider._dicMethodDataReaderGetValue[typeof(int)] = typeof(DbDataReader).GetMethod("GetDecimal", new Type[] { typeof(int) });
|
||||||
|
Select0Provider._dicMethodDataReaderGetValue[typeof(long)] = typeof(DbDataReader).GetMethod("GetDecimal", new Type[] { typeof(int) });
|
||||||
|
Select0Provider._dicMethodDataReaderGetValue[typeof(decimal)] = typeof(DbDataReader).GetMethod("GetDecimal", new Type[] { typeof(int) });
|
||||||
|
Select0Provider._dicMethodDataReaderGetValue[typeof(DateTime)] = typeof(DbDataReader).GetMethod("GetDateTime", new Type[] { typeof(int) });
|
||||||
|
Select0Provider._dicMethodDataReaderGetValue[typeof(string)] = typeof(DbDataReader).GetMethod("GetString", new Type[] { typeof(int) });
|
||||||
|
|
||||||
|
this.Aop.CommandBefore += (_, e) =>
|
||||||
|
{
|
||||||
|
if (e.Command.Parameters.Count > 0)
|
||||||
|
e.Command.CommandText = _regCommandText.Replace(e.Command.CommandText, "?");
|
||||||
|
};
|
||||||
|
|
||||||
|
this.Aop.AuditDataReader += (_, e) =>
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
readonly static Regex _regCommandText = new Regex(@"\:[_\w]+", RegexOptions.Compiled);
|
||||||
|
#else
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
~OracleProvider() => this.Dispose();
|
~OracleProvider() => this.Dispose();
|
||||||
int _disposeCounter;
|
int _disposeCounter;
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.666-preview20220823</Version>
|
<Version>3.2.666-preview20220824</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -26,6 +26,16 @@ namespace FreeSql.Oracle
|
|||||||
else value = (bool)value == true ? 1 : 0;
|
else value = (bool)value == true ? 1 : 0;
|
||||||
dbtype = OleDbType.SmallInt;
|
dbtype = OleDbType.SmallInt;
|
||||||
}
|
}
|
||||||
|
switch (dbtype)
|
||||||
|
{
|
||||||
|
case OleDbType.Char:
|
||||||
|
case OleDbType.VarChar:
|
||||||
|
case OleDbType.WChar:
|
||||||
|
case OleDbType.LongVarChar:
|
||||||
|
case OleDbType.LongVarWChar:
|
||||||
|
if (value is Guid || value is Guid?) value = string.Concat(value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
var ret = new OleDbParameter { ParameterName = QuoteParamterName(parameterName) };
|
var ret = new OleDbParameter { ParameterName = QuoteParamterName(parameterName) };
|
||||||
if (dbtype != null) ret.OleDbType = dbtype.Value;
|
if (dbtype != null) ret.OleDbType = dbtype.Value;
|
||||||
ret.Value = value;
|
ret.Value = value;
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.666-preview20220823</Version>
|
<Version>3.2.666-preview20220824</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
<Title>$(AssemblyName)</Title>
|
<Title>$(AssemblyName)</Title>
|
||||||
<IsPackable>true</IsPackable>
|
<IsPackable>true</IsPackable>
|
||||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||||
<Version>3.2.666-preview20220823</Version>
|
<Version>3.2.666-preview20220824</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<Version>3.2.666-preview20220823</Version>
|
<Version>3.2.666-preview20220824</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.666-preview20220823</Version>
|
<Version>3.2.666-preview20220824</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.666-preview20220823</Version>
|
<Version>3.2.666-preview20220824</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.666-preview20220823</Version>
|
<Version>3.2.666-preview20220824</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user