mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 10:42:52 +08:00
完成 oracle CURD测试,表达式适配和测试
This commit is contained in:
parent
b72d4abfb8
commit
dd6c0052f6
@ -1,14 +1,6 @@
|
||||
using FreeSql.DataAnnotations;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Npgsql;
|
||||
using Npgsql.LegacyPostgis;
|
||||
using NpgsqlTypes;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
using Xunit;
|
||||
|
||||
namespace FreeSql.Tests.MySqlExpression {
|
||||
@ -17,7 +9,7 @@ namespace FreeSql.Tests.MySqlExpression {
|
||||
ISelect<TableAllType> select => g.mysql.Select<TableAllType>();
|
||||
|
||||
public OtherTest() {
|
||||
NpgsqlConnection.GlobalTypeMapper.UseLegacyPostgis();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
73
FreeSql.Tests/Oracle/Curd/OracleDeleteTest.cs
Normal file
73
FreeSql.Tests/Oracle/Curd/OracleDeleteTest.cs
Normal file
@ -0,0 +1,73 @@
|
||||
using FreeSql.DataAnnotations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Xunit;
|
||||
|
||||
namespace FreeSql.Tests.Oracle {
|
||||
public class OracleDeleteTest {
|
||||
|
||||
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 TestTypeInfo Type { 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\" = 1 OR \"Id\" = 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\" = 1 OR \"Id\" = 2)", sql);
|
||||
|
||||
sql = g.oracle.Delete<Topic>(new { id = 1 }).ToSql();
|
||||
Assert.Equal("DELETE FROM \"tb_topic22211\" WHERE (\"Id\" = 1)", sql);
|
||||
}
|
||||
|
||||
[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 WhereExists() {
|
||||
|
||||
}
|
||||
[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);
|
||||
}
|
||||
}
|
||||
}
|
173
FreeSql.Tests/Oracle/Curd/OracleInsertTest.cs
Normal file
173
FreeSql.Tests/Oracle/Curd/OracleInsertTest.cs
Normal file
@ -0,0 +1,173 @@
|
||||
using FreeSql.DataAnnotations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Xunit;
|
||||
|
||||
namespace FreeSql.Tests.Oracle {
|
||||
public class OracleInsertTest {
|
||||
|
||||
IInsert<Topic> insert => g.oracle.Insert<Topic>(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
[Table(Name = "tb_topic")]
|
||||
class Topic {
|
||||
[Column(IsIdentity = true, IsPrimary = true)]
|
||||
public int Id { get; set; }
|
||||
public int? Clicks { get; set; }
|
||||
public TestTypeInfo Type { get; set; }
|
||||
public string Title { get; set; }
|
||||
public DateTime CreateTime { get; set; }
|
||||
}
|
||||
|
||||
[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\"(\"Clicks\", \"Title\", \"CreateTime\") VALUES(:Clicks0, :Title0, :CreateTime0)", sql);
|
||||
data.Add(insert.AppendData(items.First()).ExecuteIdentity());
|
||||
|
||||
sql = insert.AppendData(items).ToSql();
|
||||
Assert.Equal(@"INSERT ALL
|
||||
INTO ""tb_topic""(""Clicks"", ""Title"", ""CreateTime"") VALUES(:Clicks0, :Title0, :CreateTime0)
|
||||
INTO ""tb_topic""(""Clicks"", ""Title"", ""CreateTime"") VALUES(:Clicks1, :Title1, :CreateTime1)
|
||||
INTO ""tb_topic""(""Clicks"", ""Title"", ""CreateTime"") VALUES(:Clicks2, :Title2, :CreateTime2)
|
||||
INTO ""tb_topic""(""Clicks"", ""Title"", ""CreateTime"") VALUES(:Clicks3, :Title3, :CreateTime3)
|
||||
INTO ""tb_topic""(""Clicks"", ""Title"", ""CreateTime"") VALUES(:Clicks4, :Title4, :CreateTime4)
|
||||
INTO ""tb_topic""(""Clicks"", ""Title"", ""CreateTime"") VALUES(:Clicks5, :Title5, :CreateTime5)
|
||||
INTO ""tb_topic""(""Clicks"", ""Title"", ""CreateTime"") VALUES(:Clicks6, :Title6, :CreateTime6)
|
||||
INTO ""tb_topic""(""Clicks"", ""Title"", ""CreateTime"") VALUES(:Clicks7, :Title7, :CreateTime7)
|
||||
INTO ""tb_topic""(""Clicks"", ""Title"", ""CreateTime"") VALUES(:Clicks8, :Title8, :CreateTime8)
|
||||
INTO ""tb_topic""(""Clicks"", ""Title"", ""CreateTime"") VALUES(:Clicks9, :Title9, :CreateTime9)
|
||||
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""(""Title"") VALUES(:Title0)
|
||||
INTO ""tb_topic""(""Title"") VALUES(:Title1)
|
||||
INTO ""tb_topic""(""Title"") VALUES(:Title2)
|
||||
INTO ""tb_topic""(""Title"") VALUES(:Title3)
|
||||
INTO ""tb_topic""(""Title"") VALUES(:Title4)
|
||||
INTO ""tb_topic""(""Title"") VALUES(:Title5)
|
||||
INTO ""tb_topic""(""Title"") VALUES(:Title6)
|
||||
INTO ""tb_topic""(""Title"") VALUES(:Title7)
|
||||
INTO ""tb_topic""(""Title"") VALUES(:Title8)
|
||||
INTO ""tb_topic""(""Title"") VALUES(:Title9)
|
||||
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""(""Clicks"", ""Title"") VALUES(:Clicks0, :Title0)
|
||||
INTO ""tb_topic""(""Clicks"", ""Title"") VALUES(:Clicks1, :Title1)
|
||||
INTO ""tb_topic""(""Clicks"", ""Title"") VALUES(:Clicks2, :Title2)
|
||||
INTO ""tb_topic""(""Clicks"", ""Title"") VALUES(:Clicks3, :Title3)
|
||||
INTO ""tb_topic""(""Clicks"", ""Title"") VALUES(:Clicks4, :Title4)
|
||||
INTO ""tb_topic""(""Clicks"", ""Title"") VALUES(:Clicks5, :Title5)
|
||||
INTO ""tb_topic""(""Clicks"", ""Title"") VALUES(:Clicks6, :Title6)
|
||||
INTO ""tb_topic""(""Clicks"", ""Title"") VALUES(:Clicks7, :Title7)
|
||||
INTO ""tb_topic""(""Clicks"", ""Title"") VALUES(:Clicks8, :Title8)
|
||||
INTO ""tb_topic""(""Clicks"", ""Title"") VALUES(:Clicks9, :Title9)
|
||||
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""(""Title"") VALUES(:Title0)
|
||||
INTO ""tb_topic""(""Title"") VALUES(:Title1)
|
||||
INTO ""tb_topic""(""Title"") VALUES(:Title2)
|
||||
INTO ""tb_topic""(""Title"") VALUES(:Title3)
|
||||
INTO ""tb_topic""(""Title"") VALUES(:Title4)
|
||||
INTO ""tb_topic""(""Title"") VALUES(:Title5)
|
||||
INTO ""tb_topic""(""Title"") VALUES(:Title6)
|
||||
INTO ""tb_topic""(""Title"") VALUES(:Title7)
|
||||
INTO ""tb_topic""(""Title"") VALUES(:Title8)
|
||||
INTO ""tb_topic""(""Title"") VALUES(:Title9)
|
||||
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""(""Clicks"", ""Title"") VALUES(:Clicks0, :Title0)
|
||||
INTO ""tb_topic""(""Clicks"", ""Title"") VALUES(:Clicks1, :Title1)
|
||||
INTO ""tb_topic""(""Clicks"", ""Title"") VALUES(:Clicks2, :Title2)
|
||||
INTO ""tb_topic""(""Clicks"", ""Title"") VALUES(:Clicks3, :Title3)
|
||||
INTO ""tb_topic""(""Clicks"", ""Title"") VALUES(:Clicks4, :Title4)
|
||||
INTO ""tb_topic""(""Clicks"", ""Title"") VALUES(:Clicks5, :Title5)
|
||||
INTO ""tb_topic""(""Clicks"", ""Title"") VALUES(:Clicks6, :Title6)
|
||||
INTO ""tb_topic""(""Clicks"", ""Title"") VALUES(:Clicks7, :Title7)
|
||||
INTO ""tb_topic""(""Clicks"", ""Title"") VALUES(:Clicks8, :Title8)
|
||||
INTO ""tb_topic""(""Clicks"", ""Title"") VALUES(:Clicks9, :Title9)
|
||||
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""(""Clicks"", ""Title"") VALUES(:Clicks0, :Title0)
|
||||
INTO ""tb_topic""(""Clicks"", ""Title"") VALUES(:Clicks1, :Title1)
|
||||
INTO ""tb_topic""(""Clicks"", ""Title"") VALUES(:Clicks2, :Title2)
|
||||
INTO ""tb_topic""(""Clicks"", ""Title"") VALUES(:Clicks3, :Title3)
|
||||
INTO ""tb_topic""(""Clicks"", ""Title"") VALUES(:Clicks4, :Title4)
|
||||
INTO ""tb_topic""(""Clicks"", ""Title"") VALUES(:Clicks5, :Title5)
|
||||
INTO ""tb_topic""(""Clicks"", ""Title"") VALUES(:Clicks6, :Title6)
|
||||
INTO ""tb_topic""(""Clicks"", ""Title"") VALUES(:Clicks7, :Title7)
|
||||
INTO ""tb_topic""(""Clicks"", ""Title"") VALUES(:Clicks8, :Title8)
|
||||
INTO ""tb_topic""(""Clicks"", ""Title"") VALUES(:Clicks9, :Title9)
|
||||
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""(""Clicks"") VALUES(:Clicks0)
|
||||
INTO ""tb_topic""(""Clicks"") VALUES(:Clicks1)
|
||||
INTO ""tb_topic""(""Clicks"") VALUES(:Clicks2)
|
||||
INTO ""tb_topic""(""Clicks"") VALUES(:Clicks3)
|
||||
INTO ""tb_topic""(""Clicks"") VALUES(:Clicks4)
|
||||
INTO ""tb_topic""(""Clicks"") VALUES(:Clicks5)
|
||||
INTO ""tb_topic""(""Clicks"") VALUES(:Clicks6)
|
||||
INTO ""tb_topic""(""Clicks"") VALUES(:Clicks7)
|
||||
INTO ""tb_topic""(""Clicks"") VALUES(:Clicks8)
|
||||
INTO ""tb_topic""(""Clicks"") VALUES(:Clicks9)
|
||||
SELECT 1 FROM DUAL", sql);
|
||||
data.Add(insert.AppendData(items.First()).ExecuteIdentity());
|
||||
}
|
||||
[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());
|
||||
}
|
||||
[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();
|
||||
}
|
||||
}
|
||||
}
|
508
FreeSql.Tests/Oracle/Curd/OracleSelectTest.cs
Normal file
508
FreeSql.Tests/Oracle/Curd/OracleSelectTest.cs
Normal file
@ -0,0 +1,508 @@
|
||||
using FreeSql.DataAnnotations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Xunit;
|
||||
|
||||
namespace FreeSql.Tests.Oracle {
|
||||
public class OracleSelectTest {
|
||||
|
||||
ISelect<Topic> select => g.oracle.Select<Topic>();
|
||||
|
||||
[Table(Name = "tb_topic22")]
|
||||
class Topic {
|
||||
[Column(IsIdentity = true, IsPrimary = true)]
|
||||
public int Id { get; set; }
|
||||
public int Clicks { get; set; }
|
||||
public int TestTypeInfoGuid { 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 ToList() {
|
||||
}
|
||||
[Fact]
|
||||
public void ToOne() {
|
||||
}
|
||||
[Fact]
|
||||
public void ToSql() {
|
||||
}
|
||||
[Fact]
|
||||
public void Any() {
|
||||
var count = select.Where(a => 1 == 1).Count();
|
||||
Assert.False(select.Where(a => 1 == 2).Any());
|
||||
Assert.Equal(count > 0, select.Where(a => 1 == 1).Any());
|
||||
}
|
||||
[Fact]
|
||||
public void Count() {
|
||||
var count = select.Where(a => 1 == 1).Count();
|
||||
select.Where(a => 1 == 1).Count(out var count2);
|
||||
Assert.Equal(count, count2);
|
||||
Assert.Equal(0, select.Where(a => 1 == 2).Count());
|
||||
}
|
||||
[Fact]
|
||||
public void Master() {
|
||||
Assert.StartsWith(" SELECT", select.Master().Where(a => 1 == 1).ToSql());
|
||||
}
|
||||
[Fact]
|
||||
public void Caching() {
|
||||
var result1 = select.Where(a => 1 == 1).Caching(20, "testcaching").ToList();
|
||||
var testcaching1 = g.oracle.Cache.Get("testcaching");
|
||||
Assert.NotNull(testcaching1);
|
||||
var result2 = select.Where(a => 1 == 1).Caching(20, "testcaching").ToList();
|
||||
var testcaching2 = g.oracle.Cache.Get("testcaching");
|
||||
Assert.NotNull(testcaching2);
|
||||
Assert.Equal(result1.Count, result1.Count);
|
||||
}
|
||||
[Fact]
|
||||
public void From() {
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
var query2 = select.From<TestTypeInfo, TestTypeParentInfo>((s, b, c) => s
|
||||
.LeftJoin(a => a.TestTypeInfoGuid == b.Guid)
|
||||
.LeftJoin(a => b.ParentId == c.Id)
|
||||
);
|
||||
var sql = query2.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeInfo\" b ON a.\"TestTypeInfoGuid\" = b.\"Guid\" LEFT JOIN \"TestTypeParentInfo\" c ON b.\"ParentId\" = c.\"Id\"", sql);
|
||||
query2.ToList();
|
||||
}
|
||||
[Fact]
|
||||
public void LeftJoin() {
|
||||
//<2F><><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>a.Type<70><65>a.Type.Parent <20><><EFBFBD>ǵ<EFBFBD><C7B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
var query = select.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid);
|
||||
var sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeInfo\" a__Type ON a__Type.\"Guid\" = a.\"TestTypeInfoGuid\"", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeInfo\" a__Type ON a__Type.\"Guid\" = a.\"TestTypeInfoGuid\" AND a__Type.\"Name\" = 'xxx'", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10);
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeParentInfo\" a__Type__Parent ON 1 = 1 LEFT JOIN \"TestTypeInfo\" a__Type ON a__Type.\"Guid\" = a.\"TestTypeInfoGuid\" AND a__Type.\"Name\" = 'xxx' WHERE (a__Type__Parent.\"Id\" = 10)", sql);
|
||||
query.ToList();
|
||||
|
||||
//<2F><><EFBFBD>û<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
query = select.LeftJoin<TestTypeInfo>((a, b) => b.Guid == a.TestTypeInfoGuid);
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeInfo\" b ON b.\"Guid\" = a.\"TestTypeInfoGuid\"", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.LeftJoin<TestTypeInfo>((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeInfo\" b ON b.\"Guid\" = a.\"TestTypeInfoGuid\" AND b.\"Name\" = 'xxx'", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.LeftJoin<TestTypeInfo>((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10);
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeParentInfo\" b__Parent ON 1 = 1 LEFT JOIN \"TestTypeInfo\" b ON b.\"Guid\" = a.\"TestTypeInfoGuid\" AND b.\"Name\" = 'xxx' WHERE (b__Parent.\"Id\" = 10)", sql);
|
||||
query.ToList();
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
query = select
|
||||
.LeftJoin(a => a.Type.Guid == a.TestTypeInfoGuid)
|
||||
.LeftJoin(a => a.Type.Parent.Id == a.Type.ParentId);
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeInfo\" a__Type ON a__Type.\"Guid\" = a.\"TestTypeInfoGuid\" LEFT JOIN \"TestTypeParentInfo\" a__Type__Parent ON a__Type__Parent.\"Id\" = a__Type.\"ParentId\"", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select
|
||||
.LeftJoin<TestTypeInfo>((a, b) => b.Guid == a.TestTypeInfoGuid)
|
||||
.LeftJoin<TestTypeParentInfo>((a, c) => c.Id == a.Type.ParentId);
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeInfo\" b ON b.\"Guid\" = a.\"TestTypeInfoGuid\" LEFT JOIN \"TestTypeParentInfo\" c ON c.\"Id\" = b.\"ParentId\"", sql);
|
||||
query.ToList();
|
||||
|
||||
//<2F><><EFBFBD>û<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>b<EFBFBD><62>c<EFBFBD><63><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ
|
||||
var query2 = select.From<TestTypeInfo, TestTypeParentInfo>((s, b, c) => s
|
||||
.LeftJoin(a => a.TestTypeInfoGuid == b.Guid)
|
||||
.LeftJoin(a => b.ParentId == c.Id));
|
||||
sql = query2.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeInfo\" b ON a.\"TestTypeInfoGuid\" = b.\"Guid\" LEFT JOIN \"TestTypeParentInfo\" c ON b.\"ParentId\" = c.\"Id\"", sql);
|
||||
query2.ToList();
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD><CFB6><EFBFBD><EFBFBD>㲻<EFBFBD><E3B2BB>
|
||||
query = select.LeftJoin("\"TestTypeInfo\" b on b.\"Guid\" = a.\"TestTypeInfoGuid\"");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeInfo\" b on b.\"Guid\" = a.\"TestTypeInfoGuid\"", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.LeftJoin("\"TestTypeInfo\" b on b.\"Guid\" = a.\"TestTypeInfoGuid\" and b.\"Name\" = :bname", new { bname = "xxx" });
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeInfo\" b on b.\"Guid\" = a.\"TestTypeInfoGuid\" and b.\"Name\" = :bname", sql);
|
||||
query.ToList();
|
||||
}
|
||||
[Fact]
|
||||
public void InnerJoin() {
|
||||
//<2F><><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>a.Type<70><65>a.Type.Parent <20><><EFBFBD>ǵ<EFBFBD><C7B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
var query = select.InnerJoin(a => a.Type.Guid == a.TestTypeInfoGuid);
|
||||
var sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a INNER JOIN \"TestTypeInfo\" a__Type ON a__Type.\"Guid\" = a.\"TestTypeInfoGuid\"", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.InnerJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a INNER JOIN \"TestTypeInfo\" a__Type ON a__Type.\"Guid\" = a.\"TestTypeInfoGuid\" AND a__Type.\"Name\" = 'xxx'", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.InnerJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10);
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeParentInfo\" a__Type__Parent ON 1 = 1 INNER JOIN \"TestTypeInfo\" a__Type ON a__Type.\"Guid\" = a.\"TestTypeInfoGuid\" AND a__Type.\"Name\" = 'xxx' WHERE (a__Type__Parent.\"Id\" = 10)", sql);
|
||||
query.ToList();
|
||||
|
||||
//<2F><><EFBFBD>û<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
query = select.InnerJoin<TestTypeInfo>((a, b) => b.Guid == a.TestTypeInfoGuid);
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a INNER JOIN \"TestTypeInfo\" b ON b.\"Guid\" = a.\"TestTypeInfoGuid\"", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.InnerJoin<TestTypeInfo>((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a INNER JOIN \"TestTypeInfo\" b ON b.\"Guid\" = a.\"TestTypeInfoGuid\" AND b.\"Name\" = 'xxx'", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.InnerJoin<TestTypeInfo>((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10);
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeParentInfo\" b__Parent ON 1 = 1 INNER JOIN \"TestTypeInfo\" b ON b.\"Guid\" = a.\"TestTypeInfoGuid\" AND b.\"Name\" = 'xxx' WHERE (b__Parent.\"Id\" = 10)", sql);
|
||||
query.ToList();
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
query = select
|
||||
.InnerJoin(a => a.Type.Guid == a.TestTypeInfoGuid)
|
||||
.InnerJoin(a => a.Type.Parent.Id == a.Type.ParentId);
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a INNER JOIN \"TestTypeInfo\" a__Type ON a__Type.\"Guid\" = a.\"TestTypeInfoGuid\" INNER JOIN \"TestTypeParentInfo\" a__Type__Parent ON a__Type__Parent.\"Id\" = a__Type.\"ParentId\"", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select
|
||||
.InnerJoin<TestTypeInfo>((a, b) => b.Guid == a.TestTypeInfoGuid)
|
||||
.InnerJoin<TestTypeParentInfo>((a, c) => c.Id == a.Type.ParentId);
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a INNER JOIN \"TestTypeInfo\" b ON b.\"Guid\" = a.\"TestTypeInfoGuid\" INNER JOIN \"TestTypeParentInfo\" c ON c.\"Id\" = b.\"ParentId\"", sql);
|
||||
query.ToList();
|
||||
|
||||
//<2F><><EFBFBD>û<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>b<EFBFBD><62>c<EFBFBD><63><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ
|
||||
var query2 = select.From<TestTypeInfo, TestTypeParentInfo>((s, b, c) => s
|
||||
.InnerJoin(a => a.TestTypeInfoGuid == b.Guid)
|
||||
.InnerJoin(a => b.ParentId == c.Id));
|
||||
sql = query2.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a INNER JOIN \"TestTypeInfo\" b ON a.\"TestTypeInfoGuid\" = b.\"Guid\" INNER JOIN \"TestTypeParentInfo\" c ON b.\"ParentId\" = c.\"Id\"", sql);
|
||||
query2.ToList();
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD><CFB6><EFBFBD><EFBFBD>㲻<EFBFBD><E3B2BB>
|
||||
query = select.InnerJoin("\"TestTypeInfo\" b on b.\"Guid\" = a.\"TestTypeInfoGuid\"");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a INNER JOIN \"TestTypeInfo\" b on b.\"Guid\" = a.\"TestTypeInfoGuid\"", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.InnerJoin("\"TestTypeInfo\" b on b.\"Guid\" = a.\"TestTypeInfoGuid\" and b.\"Name\" = :bname", new { bname = "xxx" });
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a INNER JOIN \"TestTypeInfo\" b on b.\"Guid\" = a.\"TestTypeInfoGuid\" and b.\"Name\" = :bname", sql);
|
||||
query.ToList();
|
||||
|
||||
}
|
||||
[Fact]
|
||||
public void RightJoin() {
|
||||
//<2F><><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>a.Type<70><65>a.Type.Parent <20><><EFBFBD>ǵ<EFBFBD><C7B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
var query = select.RightJoin(a => a.Type.Guid == a.TestTypeInfoGuid);
|
||||
var sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a RIGHT JOIN \"TestTypeInfo\" a__Type ON a__Type.\"Guid\" = a.\"TestTypeInfoGuid\"", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.RightJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a RIGHT JOIN \"TestTypeInfo\" a__Type ON a__Type.\"Guid\" = a.\"TestTypeInfoGuid\" AND a__Type.\"Name\" = 'xxx'", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.RightJoin(a => a.Type.Guid == a.TestTypeInfoGuid && a.Type.Name == "xxx").Where(a => a.Type.Parent.Id == 10);
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeParentInfo\" a__Type__Parent ON 1 = 1 RIGHT JOIN \"TestTypeInfo\" a__Type ON a__Type.\"Guid\" = a.\"TestTypeInfoGuid\" AND a__Type.\"Name\" = 'xxx' WHERE (a__Type__Parent.\"Id\" = 10)", sql);
|
||||
query.ToList();
|
||||
|
||||
//<2F><><EFBFBD>û<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
query = select.RightJoin<TestTypeInfo>((a, b) => b.Guid == a.TestTypeInfoGuid);
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a RIGHT JOIN \"TestTypeInfo\" b ON b.\"Guid\" = a.\"TestTypeInfoGuid\"", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.RightJoin<TestTypeInfo>((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a RIGHT JOIN \"TestTypeInfo\" b ON b.\"Guid\" = a.\"TestTypeInfoGuid\" AND b.\"Name\" = 'xxx'", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.RightJoin<TestTypeInfo>((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "xxx").Where(a => a.Type.Parent.Id == 10);
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a LEFT JOIN \"TestTypeParentInfo\" b__Parent ON 1 = 1 RIGHT JOIN \"TestTypeInfo\" b ON b.\"Guid\" = a.\"TestTypeInfoGuid\" AND b.\"Name\" = 'xxx' WHERE (b__Parent.\"Id\" = 10)", sql);
|
||||
query.ToList();
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
query = select
|
||||
.RightJoin(a => a.Type.Guid == a.TestTypeInfoGuid)
|
||||
.RightJoin(a => a.Type.Parent.Id == a.Type.ParentId);
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a RIGHT JOIN \"TestTypeInfo\" a__Type ON a__Type.\"Guid\" = a.\"TestTypeInfoGuid\" RIGHT JOIN \"TestTypeParentInfo\" a__Type__Parent ON a__Type__Parent.\"Id\" = a__Type.\"ParentId\"", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select
|
||||
.RightJoin<TestTypeInfo>((a, b) => b.Guid == a.TestTypeInfoGuid)
|
||||
.RightJoin<TestTypeParentInfo>((a, c) => c.Id == a.Type.ParentId);
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a RIGHT JOIN \"TestTypeInfo\" b ON b.\"Guid\" = a.\"TestTypeInfoGuid\" RIGHT JOIN \"TestTypeParentInfo\" c ON c.\"Id\" = b.\"ParentId\"", sql);
|
||||
query.ToList();
|
||||
|
||||
//<2F><><EFBFBD>û<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>b<EFBFBD><62>c<EFBFBD><63><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ
|
||||
var query2 = select.From<TestTypeInfo, TestTypeParentInfo>((s, b, c) => s
|
||||
.RightJoin(a => a.TestTypeInfoGuid == b.Guid)
|
||||
.RightJoin(a => b.ParentId == c.Id));
|
||||
sql = query2.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a RIGHT JOIN \"TestTypeInfo\" b ON a.\"TestTypeInfoGuid\" = b.\"Guid\" RIGHT JOIN \"TestTypeParentInfo\" c ON b.\"ParentId\" = c.\"Id\"", sql);
|
||||
query2.ToList();
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD><CFB6><EFBFBD><EFBFBD>㲻<EFBFBD><E3B2BB>
|
||||
query = select.RightJoin("\"TestTypeInfo\" b on b.\"Guid\" = a.\"TestTypeInfoGuid\"");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a RIGHT JOIN \"TestTypeInfo\" b on b.\"Guid\" = a.\"TestTypeInfoGuid\"", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.RightJoin("\"TestTypeInfo\" b on b.\"Guid\" = a.\"TestTypeInfoGuid\" and b.\"Name\" = :bname", new { bname = "xxx" });
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a RIGHT JOIN \"TestTypeInfo\" b on b.\"Guid\" = a.\"TestTypeInfoGuid\" and b.\"Name\" = :bname", sql);
|
||||
query.ToList();
|
||||
|
||||
}
|
||||
[Fact]
|
||||
public void Where() {
|
||||
//<2F><><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>a.Type<70><65>a.Type.Parent <20><><EFBFBD>ǵ<EFBFBD><C7B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
var query = select.Where(a => a.Id == 10);
|
||||
var sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a WHERE (a.\"Id\" = 10)", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.Where(a => a.Id == 10 && a.Id > 10 || a.Clicks > 100);
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a WHERE (a.\"Id\" = 10 AND a.\"Id\" > 10 OR a.\"Clicks\" > 100)", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.Where(a => a.Id == 10).Where(a => a.Clicks > 100);
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a WHERE (a.\"Id\" = 10) AND (a.\"Clicks\" > 100)", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.Where(a => a.Type.Name == "typeTitle");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type WHERE (a__Type.\"Name\" = 'typeTitle')", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.Where(a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TestTypeInfoGuid);
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type WHERE (a__Type.\"Name\" = 'typeTitle' AND a__Type.\"Guid\" = a.\"TestTypeInfoGuid\")", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.Where(a => a.Type.Parent.Name == "tparent");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type, \"TestTypeParentInfo\" a__Type__Parent WHERE (a__Type__Parent.\"Name\" = 'tparent')", sql);
|
||||
query.ToList();
|
||||
|
||||
//<2F><><EFBFBD>û<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԣ<EFBFBD><D4A3><EFBFBD><F2B5A5B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
query = select.Where<TestTypeInfo>((a, b) => b.Guid == a.TestTypeInfoGuid && b.Name == "typeTitle");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" b WHERE (b.\"Guid\" = a.\"TestTypeInfoGuid\" AND b.\"Name\" = 'typeTitle')", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.Where<TestTypeInfo>((a, b) => b.Name == "typeTitle" && b.Guid == a.TestTypeInfoGuid);
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" b WHERE (b.\"Name\" = 'typeTitle' AND b.\"Guid\" = a.\"TestTypeInfoGuid\")", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.Where<TestTypeInfo, TestTypeParentInfo>((a, b, c) => c.Name == "tparent");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeParentInfo\" c WHERE (c.\"Name\" = 'tparent')", sql);
|
||||
query.ToList();
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB> From <20><>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
var query2 = select.From<TestTypeInfo, TestTypeParentInfo>((s, b, c) => s
|
||||
.Where(a => a.Id == 10 && c.Name == "xxx")
|
||||
.Where(a => b.ParentId == 20));
|
||||
sql = query2.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeParentInfo\" c, \"TestTypeInfo\" b WHERE (a.\"Id\" = 10 AND c.\"Name\" = 'xxx') AND (b.\"ParentId\" = 20)", sql);
|
||||
query2.ToList();
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD><CFB6><EFBFBD><EFBFBD>㲻<EFBFBD><E3B2BB>
|
||||
query = select.Where("a.\"Clicks\" > 100 and a.\"Id\" = :id", new { id = 10 });
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a WHERE (a.\"Clicks\" > 100 and a.\"Id\" = :id)", sql);
|
||||
query.ToList();
|
||||
}
|
||||
[Fact]
|
||||
public void WhereIf() {
|
||||
//<2F><><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>a.Type<70><65>a.Type.Parent <20><><EFBFBD>ǵ<EFBFBD><C7B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
var query = select.WhereIf(true, a => a.Id == 10);
|
||||
var sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a WHERE (a.\"Id\" = 10)", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.WhereIf(true, a => a.Id == 10 && a.Id > 10 || a.Clicks > 100);
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a WHERE (a.\"Id\" = 10 AND a.\"Id\" > 10 OR a.\"Clicks\" > 100)", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.WhereIf(true, a => a.Id == 10).WhereIf(true, a => a.Clicks > 100);
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a WHERE (a.\"Id\" = 10) AND (a.\"Clicks\" > 100)", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.WhereIf(true, a => a.Type.Name == "typeTitle");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type WHERE (a__Type.\"Name\" = 'typeTitle')", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.WhereIf(true, a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TestTypeInfoGuid);
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type WHERE (a__Type.\"Name\" = 'typeTitle' AND a__Type.\"Guid\" = a.\"TestTypeInfoGuid\")", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.WhereIf(true, a => a.Type.Parent.Name == "tparent");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a__Type.\"Guid\", a__Type.\"ParentId\", a__Type.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeInfo\" a__Type, \"TestTypeParentInfo\" a__Type__Parent WHERE (a__Type__Parent.\"Name\" = 'tparent')", sql);
|
||||
query.ToList();
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB> From <20><>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
var query2 = select.From<TestTypeInfo, TestTypeParentInfo>((s, b, c) => s
|
||||
.WhereIf(true, a => a.Id == 10 && c.Name == "xxx")
|
||||
.WhereIf(true, a => b.ParentId == 20));
|
||||
sql = query2.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", b.\"Guid\", b.\"ParentId\", b.\"Name\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a, \"TestTypeParentInfo\" c, \"TestTypeInfo\" b WHERE (a.\"Id\" = 10 AND c.\"Name\" = 'xxx') AND (b.\"ParentId\" = 20)", sql);
|
||||
query2.ToList();
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD><CFB6><EFBFBD><EFBFBD>㲻<EFBFBD><E3B2BB>
|
||||
query = select.WhereIf(true, "a.\"Clicks\" > 100 and a.\"Id\" = :id", new { id = 10 });
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a WHERE (a.\"Clicks\" > 100 and a.\"Id\" = :id)", sql);
|
||||
query.ToList();
|
||||
|
||||
// ==========================================WhereIf(false)
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>a.Type<70><65>a.Type.Parent <20><><EFBFBD>ǵ<EFBFBD><C7B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
query = select.WhereIf(false, a => a.Id == 10);
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.WhereIf(false, a => a.Id == 10 && a.Id > 10 || a.Clicks > 100);
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.WhereIf(false, a => a.Id == 10).WhereIf(false, a => a.Clicks > 100);
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.WhereIf(false, a => a.Type.Name == "typeTitle");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.WhereIf(false, a => a.Type.Name == "typeTitle" && a.Type.Guid == a.TestTypeInfoGuid);
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a", sql);
|
||||
query.ToList();
|
||||
|
||||
query = select.WhereIf(false, a => a.Type.Parent.Name == "tparent");
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a", sql);
|
||||
query.ToList();
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB> From <20><>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
query2 = select.From<TestTypeInfo, TestTypeParentInfo>((s, b, c) => s
|
||||
.WhereIf(false, a => a.Id == 10 && c.Name == "xxx")
|
||||
.WhereIf(false, a => b.ParentId == 20));
|
||||
sql = query2.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a", sql);
|
||||
query2.ToList();
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD><CFB6><EFBFBD><EFBFBD>㲻<EFBFBD><E3B2BB>
|
||||
query = select.WhereIf(false, "a.\"Clicks\" > 100 and a.\"Id\" = :id", new { id = 10 });
|
||||
sql = query.ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.\"Id\", a.\"Clicks\", a.\"TestTypeInfoGuid\", a.\"Title\", a.\"CreateTime\" FROM \"tb_topic22\" a", sql);
|
||||
query.ToList();
|
||||
}
|
||||
[Fact]
|
||||
public void WhereExists() {
|
||||
var sql2222 = select.Where(a => select.Where(b => b.Id == a.Id).Any()).ToList();
|
||||
|
||||
sql2222 = select.Where(a =>
|
||||
select.Where(b => b.Id == a.Id && select.Where(c => c.Id == b.Id).Where(d => d.Id == a.Id).Where(e => e.Id == b.Id)
|
||||
|
||||
.Offset(a.Id)
|
||||
|
||||
.Any()
|
||||
).Any()
|
||||
).ToList();
|
||||
}
|
||||
[Fact]
|
||||
public void GroupBy() {
|
||||
var groupby = select.From<TestTypeInfo, TestTypeParentInfo>((s, b, c) => s
|
||||
.Where(a => a.Id == 1)
|
||||
)
|
||||
.GroupBy((a, b, c) => new { tt2 = a.Title.Substring(0, 2), mod4 = a.Id % 4 })
|
||||
.Having(a => a.Count() > 0 && a.Avg(a.Key.mod4) > 0 && a.Max(a.Key.mod4) > 0)
|
||||
.Having(a => a.Count() < 300 || a.Avg(a.Key.mod4) < 100)
|
||||
.OrderBy(a => a.Key.tt2)
|
||||
.OrderByDescending(a => a.Count())
|
||||
.ToList(a => new {
|
||||
a.Key.tt2,
|
||||
cou1 = a.Count(),
|
||||
arg1 = a.Avg(a.Key.mod4),
|
||||
ccc2 = a.Key.tt2 ?? "now()",
|
||||
//ccc = Convert.ToDateTime("now()"), partby = Convert.ToDecimal("sum(num) over(PARTITION BY server_id,os,rid,chn order by id desc)")
|
||||
});
|
||||
}
|
||||
[Fact]
|
||||
public void ToAggregate() {
|
||||
var sql = select.ToAggregate(a => new { sum = a.Sum(a.Key.Id + 11.11), avg = a.Avg(a.Key.Id), count = a.Count(), max = a.Max(a.Key.Id), min = a.Min(a.Key.Id) });
|
||||
}
|
||||
[Fact]
|
||||
public void OrderBy() {
|
||||
}
|
||||
[Fact]
|
||||
public void Skip_Offset() {
|
||||
}
|
||||
[Fact]
|
||||
public void Take_Limit() {
|
||||
}
|
||||
[Fact]
|
||||
public void Page() {
|
||||
}
|
||||
[Fact]
|
||||
public void Sum() {
|
||||
}
|
||||
[Fact]
|
||||
public void Min() {
|
||||
}
|
||||
[Fact]
|
||||
public void Max() {
|
||||
}
|
||||
[Fact]
|
||||
public void Avg() {
|
||||
}
|
||||
[Fact]
|
||||
public void As() {
|
||||
}
|
||||
}
|
||||
}
|
107
FreeSql.Tests/Oracle/Curd/OracleUpdateTest.cs
Normal file
107
FreeSql.Tests/Oracle/Curd/OracleUpdateTest.cs
Normal file
@ -0,0 +1,107 @@
|
||||
using FreeSql.DataAnnotations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Xunit;
|
||||
|
||||
namespace FreeSql.Tests.Oracle {
|
||||
public class OracleUpdateTest {
|
||||
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 TestTypeInfo Type { 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\" = 1 OR \"Id\" = 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\" = 1 OR \"Id\" = 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 });
|
||||
|
||||
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);
|
||||
}
|
||||
[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 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\" = 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\" = 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);
|
||||
}
|
||||
[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 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 WhereExists() {
|
||||
|
||||
}
|
||||
[Fact]
|
||||
public void ExecuteAffrows() {
|
||||
|
||||
}
|
||||
[Fact]
|
||||
public void ExecuteUpdated() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
54
FreeSql.Tests/Oracle/OracleAdo/OracleAdoTest.cs
Normal file
54
FreeSql.Tests/Oracle/OracleAdo/OracleAdoTest.cs
Normal file
@ -0,0 +1,54 @@
|
||||
using FreeSql.DataAnnotations;
|
||||
using System;
|
||||
using Xunit;
|
||||
|
||||
namespace FreeSql.Tests.Oracle {
|
||||
public class OracleAdoTest {
|
||||
[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 IsTracePerformance() {
|
||||
Assert.True(g.oracle.Ado.IsTracePerformance);
|
||||
}
|
||||
|
||||
[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 \"song\"");
|
||||
|
||||
var t4 = g.oracle.Ado.Query<(int, string, string)>("select * from \"song\"");
|
||||
|
||||
var t5 = g.oracle.Ado.Query<dynamic>("select * from \"song\"");
|
||||
}
|
||||
|
||||
class xxx {
|
||||
public int Id { get; set; }
|
||||
public string Path { get; set; }
|
||||
public string Title2 { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
@ -36,48 +36,48 @@ namespace FreeSql.Tests.Oracle {
|
||||
if (string.IsNullOrEmpty(sql) == false) {
|
||||
Assert.Equal(@"CREATE TABLE IF NOT EXISTS `cccddd`.`tb_alltype` (
|
||||
`Id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`testFieldBool` BIT(1) NOT NULL,
|
||||
`testFieldSByte` TINYINT(3) NOT NULL,
|
||||
`testFieldShort` SMALLINT(6) NOT NULL,
|
||||
`testFieldInt` INT(11) NOT NULL,
|
||||
`testFieldLong` BIGINT(20) NOT NULL,
|
||||
`testFieldByte` TINYINT(3) UNSIGNED NOT NULL,
|
||||
`testFieldUShort` SMALLINT(5) UNSIGNED NOT NULL,
|
||||
`testFieldUInt` INT(10) UNSIGNED NOT NULL,
|
||||
`testFieldULong` BIGINT(20) UNSIGNED NOT NULL,
|
||||
`testFieldDouble` DOUBLE NOT NULL,
|
||||
`testFieldFloat` FLOAT NOT NULL,
|
||||
`testFieldDecimal` DECIMAL(10,2) NOT NULL,
|
||||
`testFieldTimeSpan` TIME NOT NULL,
|
||||
`testFieldDateTime` DATETIME NOT NULL,
|
||||
`testFieldBytes` VARBINARY(255),
|
||||
`testFieldString` VARCHAR(255),
|
||||
`testFieldGuid` VARCHAR(36),
|
||||
`testFieldBoolNullable` BIT(1),
|
||||
`testFieldSByteNullable` TINYINT(3),
|
||||
`testFieldShortNullable` SMALLINT(6),
|
||||
`testFieldIntNullable` INT(11),
|
||||
`Bool` BIT(1) NOT NULL,
|
||||
`SByte` TINYINT(3) NOT NULL,
|
||||
`Short` SMALLINT(6) NOT NULL,
|
||||
`Int` INT(11) NOT NULL,
|
||||
`Long` BIGINT(20) NOT NULL,
|
||||
`Byte` TINYINT(3) UNSIGNED NOT NULL,
|
||||
`UShort` SMALLINT(5) UNSIGNED NOT NULL,
|
||||
`UInt` INT(10) UNSIGNED NOT NULL,
|
||||
`ULong` BIGINT(20) UNSIGNED NOT NULL,
|
||||
`Double` DOUBLE NOT NULL,
|
||||
`Float` FLOAT NOT NULL,
|
||||
`Decimal` DECIMAL(10,2) NOT NULL,
|
||||
`TimeSpan` TIME NOT NULL,
|
||||
`DateTime` DATETIME NOT NULL,
|
||||
`Bytes` VARBINARY(255),
|
||||
`String` VARCHAR(255),
|
||||
`Guid` VARCHAR(36),
|
||||
`BoolNullable` BIT(1),
|
||||
`SByteNullable` TINYINT(3),
|
||||
`ShortNullable` SMALLINT(6),
|
||||
`IntNullable` INT(11),
|
||||
`testFielLongNullable` BIGINT(20),
|
||||
`testFieldByteNullable` TINYINT(3) UNSIGNED,
|
||||
`testFieldUShortNullable` SMALLINT(5) UNSIGNED,
|
||||
`testFieldUIntNullable` INT(10) UNSIGNED,
|
||||
`testFieldULongNullable` BIGINT(20) UNSIGNED,
|
||||
`testFieldDoubleNullable` DOUBLE,
|
||||
`testFieldFloatNullable` FLOAT,
|
||||
`testFieldDecimalNullable` DECIMAL(10,2),
|
||||
`testFieldTimeSpanNullable` TIME,
|
||||
`testFieldDateTimeNullable` DATETIME,
|
||||
`testFieldGuidNullable` VARCHAR(36),
|
||||
`testFieldPoint` POINT,
|
||||
`testFieldLineString` LINESTRING,
|
||||
`testFieldPolygon` POLYGON,
|
||||
`testFieldMultiPoint` MULTIPOINT,
|
||||
`testFieldMultiLineString` MULTILINESTRING,
|
||||
`testFieldMultiPolygon` MULTIPOLYGON,
|
||||
`testFieldEnum1` ENUM('E1','E2','E3') NOT NULL,
|
||||
`testFieldEnum1Nullable` ENUM('E1','E2','E3'),
|
||||
`testFieldEnum2` SET('F1','F2','F3') NOT NULL,
|
||||
`testFieldEnum2Nullable` SET('F1','F2','F3'),
|
||||
`ByteNullable` TINYINT(3) UNSIGNED,
|
||||
`UShortNullable` SMALLINT(5) UNSIGNED,
|
||||
`UIntNullable` INT(10) UNSIGNED,
|
||||
`ULongNullable` BIGINT(20) UNSIGNED,
|
||||
`DoubleNullable` DOUBLE,
|
||||
`FloatNullable` FLOAT,
|
||||
`DecimalNullable` DECIMAL(10,2),
|
||||
`TimeSpanNullable` TIME,
|
||||
`DateTimeNullable` DATETIME,
|
||||
`GuidNullable` VARCHAR(36),
|
||||
`Point` POINT,
|
||||
`LineString` LINESTRING,
|
||||
`Polygon` POLYGON,
|
||||
`MultiPoint` MULTIPOINT,
|
||||
`MultiLineString` MULTILINESTRING,
|
||||
`MultiPolygon` MULTIPOLYGON,
|
||||
`Enum1` ENUM('E1','E2','E3') NOT NULL,
|
||||
`Enum1Nullable` ENUM('E1','E2','E3'),
|
||||
`Enum2` SET('F1','F2','F3') NOT NULL,
|
||||
`Enum2Nullable` SET('F1','F2','F3'),
|
||||
PRIMARY KEY (`Id`)
|
||||
) Engine=InnoDB CHARACTER SET utf8;
|
||||
", sql);
|
||||
@ -97,63 +97,40 @@ namespace FreeSql.Tests.Oracle {
|
||||
var newitem = select.Where(a => a.Id == item.Id).ToOne();
|
||||
|
||||
var item2 = new TableAllType {
|
||||
testFieldBool = true,
|
||||
testFieldBoolNullable = true,
|
||||
testFieldByte = 255,
|
||||
testFieldByteNullable = 127,
|
||||
testFieldBytes = Encoding.UTF8.GetBytes("ÎÒÊÇÖйúÈË"),
|
||||
testFieldDateTime = DateTime.Now,
|
||||
testFieldDateTimeNullable = DateTime.Now.AddHours(-1),
|
||||
testFieldDecimal = 99.99M,
|
||||
testFieldDecimalNullable = 99.98M,
|
||||
testFieldDouble = 999.99,
|
||||
testFieldDoubleNullable = 999.98,
|
||||
testFieldEnum1 = TableAllTypeEnumType1.e5,
|
||||
testFieldEnum1Nullable = TableAllTypeEnumType1.e3,
|
||||
testFieldEnum2 = TableAllTypeEnumType2.f2,
|
||||
testFieldEnum2Nullable = TableAllTypeEnumType2.f3,
|
||||
testFieldFloat = 19.99F,
|
||||
testFieldFloatNullable = 19.98F,
|
||||
testFieldGuid = Guid.NewGuid(),
|
||||
testFieldGuidNullable = Guid.NewGuid(),
|
||||
testFieldInt = int.MaxValue,
|
||||
testFieldIntNullable = int.MinValue,
|
||||
testFieldLineString = new MygisLineString(new[] { new MygisCoordinate2D(10, 10), new MygisCoordinate2D(50, 10) }),
|
||||
testFieldLong = long.MaxValue,
|
||||
testFieldMultiLineString = new MygisMultiLineString(new[] {
|
||||
new[] { new MygisCoordinate2D(10, 10), new MygisCoordinate2D(50, 10) },
|
||||
new[] { new MygisCoordinate2D(50, 10), new MygisCoordinate2D(10, 100) } }),
|
||||
testFieldMultiPoint = new MygisMultiPoint(new[] { new MygisCoordinate2D(11, 11), new MygisCoordinate2D(51, 11) }),
|
||||
testFieldMultiPolygon = new MygisMultiPolygon(new[] {
|
||||
new MygisPolygon(new[] {
|
||||
new[] { new MygisCoordinate2D(10, 10), new MygisCoordinate2D(50, 10), new MygisCoordinate2D(10, 50), new MygisCoordinate2D(10, 10) },
|
||||
new[] { new MygisCoordinate2D(10, 10), new MygisCoordinate2D(50, 10), new MygisCoordinate2D(10, 50), new MygisCoordinate2D(10, 10) },
|
||||
new[] { new MygisCoordinate2D(10, 10), new MygisCoordinate2D(50, 10), new MygisCoordinate2D(10, 50), new MygisCoordinate2D(10, 10) },
|
||||
new[] { new MygisCoordinate2D(10, 10), new MygisCoordinate2D(50, 10), new MygisCoordinate2D(10, 50), new MygisCoordinate2D(10, 10) } }),
|
||||
new MygisPolygon(new[] {
|
||||
new[] { new MygisCoordinate2D(10, 10), new MygisCoordinate2D(50, 10), new MygisCoordinate2D(10, 50), new MygisCoordinate2D(10, 10) },
|
||||
new[] { new MygisCoordinate2D(10, 10), new MygisCoordinate2D(50, 10), new MygisCoordinate2D(10, 50), new MygisCoordinate2D(10, 10) },
|
||||
new[] { new MygisCoordinate2D(10, 10), new MygisCoordinate2D(50, 10), new MygisCoordinate2D(10, 50), new MygisCoordinate2D(10, 10) },
|
||||
new[] { new MygisCoordinate2D(10, 10), new MygisCoordinate2D(50, 10), new MygisCoordinate2D(10, 50), new MygisCoordinate2D(10, 10) } }) }),
|
||||
testFieldPoint = new MygisPoint(99, 99),
|
||||
testFieldPolygon = new MygisPolygon(new[] {
|
||||
new[] { new MygisCoordinate2D(10, 10), new MygisCoordinate2D(50, 10), new MygisCoordinate2D(10, 50), new MygisCoordinate2D(10, 10) },
|
||||
new[] { new MygisCoordinate2D(10, 10), new MygisCoordinate2D(50, 10), new MygisCoordinate2D(10, 50), new MygisCoordinate2D(10, 10) },
|
||||
new[] { new MygisCoordinate2D(10, 10), new MygisCoordinate2D(50, 10), new MygisCoordinate2D(10, 50), new MygisCoordinate2D(10, 10) },
|
||||
new[] { new MygisCoordinate2D(10, 10), new MygisCoordinate2D(50, 10), new MygisCoordinate2D(10, 50), new MygisCoordinate2D(10, 10) } }),
|
||||
testFieldSByte = 100,
|
||||
testFieldSByteNullable = 99,
|
||||
testFieldShort = short.MaxValue,
|
||||
testFieldShortNullable = short.MinValue,
|
||||
testFieldString = "ÎÒÊÇÖйúÈËstring",
|
||||
testFieldTimeSpan = TimeSpan.FromSeconds(999),
|
||||
testFieldTimeSpanNullable = TimeSpan.FromSeconds(60),
|
||||
testFieldUInt = uint.MaxValue,
|
||||
testFieldUIntNullable = uint.MinValue,
|
||||
testFieldULong = ulong.MaxValue,
|
||||
testFieldULongNullable = ulong.MinValue,
|
||||
testFieldUShort = ushort.MaxValue,
|
||||
testFieldUShortNullable = ushort.MinValue,
|
||||
Bool = true,
|
||||
BoolNullable = true,
|
||||
Byte = 255,
|
||||
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",
|
||||
TimeSpan = TimeSpan.FromSeconds(999),
|
||||
TimeSpanNullable = TimeSpan.FromSeconds(60),
|
||||
UInt = uint.MaxValue,
|
||||
UIntNullable = uint.MinValue,
|
||||
ULong = ulong.MaxValue,
|
||||
ULongNullable = ulong.MinValue,
|
||||
UShort = ushort.MaxValue,
|
||||
UShortNullable = ushort.MinValue,
|
||||
testFielLongNullable = long.MinValue
|
||||
};
|
||||
item2.Id = (int)insert.AppendData(item2).ExecuteIdentity();
|
||||
@ -167,51 +144,48 @@ namespace FreeSql.Tests.Oracle {
|
||||
[Column(IsIdentity = true, IsPrimary = true)]
|
||||
public int Id { get; set; }
|
||||
|
||||
public bool testFieldBool { get; set; }
|
||||
public sbyte testFieldSByte { get; set; }
|
||||
public short testFieldShort { get; set; }
|
||||
public int testFieldInt { get; set; }
|
||||
public long testFieldLong { get; set; }
|
||||
public byte testFieldByte { get; set; }
|
||||
public ushort testFieldUShort { get; set; }
|
||||
public uint testFieldUInt { get; set; }
|
||||
public ulong testFieldULong { get; set; }
|
||||
public double testFieldDouble { get; set; }
|
||||
public float testFieldFloat { get; set; }
|
||||
public decimal testFieldDecimal { get; set; }
|
||||
public TimeSpan testFieldTimeSpan { get; set; }
|
||||
public DateTime testFieldDateTime { get; set; }
|
||||
public byte[] testFieldBytes { get; set; }
|
||||
public string testFieldString { get; set; }
|
||||
public Guid testFieldGuid { get; set; }
|
||||
public string id2 { get; set; } = "id2=10";
|
||||
|
||||
public bool? testFieldBoolNullable { get; set; }
|
||||
public sbyte? testFieldSByteNullable { get; set; }
|
||||
public short? testFieldShortNullable { get; set; }
|
||||
public int? testFieldIntNullable { get; set; }
|
||||
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? testFieldByteNullable { get; set; }
|
||||
public ushort? testFieldUShortNullable { get; set; }
|
||||
public uint? testFieldUIntNullable { get; set; }
|
||||
public ulong? testFieldULongNullable { get; set; }
|
||||
public double? testFieldDoubleNullable { get; set; }
|
||||
public float? testFieldFloatNullable { get; set; }
|
||||
public decimal? testFieldDecimalNullable { get; set; }
|
||||
public TimeSpan? testFieldTimeSpanNullable { get; set; }
|
||||
public DateTime? testFieldDateTimeNullable { get; set; }
|
||||
public Guid? testFieldGuidNullable { 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 MygisPoint testFieldPoint { get; set; }
|
||||
public MygisLineString testFieldLineString { get; set; }
|
||||
public MygisPolygon testFieldPolygon { get; set; }
|
||||
public MygisMultiPoint testFieldMultiPoint { get; set; }
|
||||
public MygisMultiLineString testFieldMultiLineString { get; set; }
|
||||
public MygisMultiPolygon testFieldMultiPolygon { get; set; }
|
||||
|
||||
public TableAllTypeEnumType1 testFieldEnum1 { get; set; }
|
||||
public TableAllTypeEnumType1? testFieldEnum1Nullable { get; set; }
|
||||
public TableAllTypeEnumType2 testFieldEnum2 { get; set; }
|
||||
public TableAllTypeEnumType2? testFieldEnum2Nullable { 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 }
|
||||
|
114
FreeSql.Tests/Oracle/OracleExpression/ConvertTest.cs
Normal file
114
FreeSql.Tests/Oracle/OracleExpression/ConvertTest.cs
Normal file
@ -0,0 +1,114 @@
|
||||
using FreeSql.DataAnnotations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Xunit;
|
||||
|
||||
namespace FreeSql.Tests.OracleExpression {
|
||||
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 TestTypeInfoGuid { 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 : 2) > 0).ToList());
|
||||
//SELECT a.`Id`, a.`Clicks`, a.`TestTypeInfoGuid`, a.`Title`, a.`CreateTime`
|
||||
//FROM `tb_topic` a
|
||||
//WHERE ((a.`Clicks` not in ('0','false')))
|
||||
}
|
||||
[Fact]
|
||||
public void ToByte() {
|
||||
var data = new List<object>();
|
||||
data.Add(select.Where(a => Convert.ToByte(a.Clicks) > 0).ToList());
|
||||
}
|
||||
[Fact]
|
||||
public void ToChar() {
|
||||
var data = new List<object>();
|
||||
data.Add(select.Where(a => Convert.ToChar(a.Clicks) == 'a').ToList());
|
||||
}
|
||||
[Fact]
|
||||
public void ToDateTime() {
|
||||
var data = new List<object>();
|
||||
data.Add(select.Where(a => Convert.ToDateTime(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());
|
||||
}
|
||||
[Fact]
|
||||
public void ToDouble() {
|
||||
var data = new List<object>();
|
||||
data.Add(select.Where(a => Convert.ToDouble(a.Clicks) > 0).ToList());
|
||||
}
|
||||
[Fact]
|
||||
public void ToInt16() {
|
||||
var data = new List<object>();
|
||||
data.Add(select.Where(a => Convert.ToInt16(a.Clicks) > 0).ToList());
|
||||
}
|
||||
[Fact]
|
||||
public void ToInt32() {
|
||||
var data = new List<object>();
|
||||
data.Add(select.Where(a => Convert.ToInt32(a.Clicks) > 0).ToList());
|
||||
}
|
||||
[Fact]
|
||||
public void ToInt64() {
|
||||
var data = new List<object>();
|
||||
data.Add(select.Where(a => Convert.ToInt64(a.Clicks) > 0).ToList());
|
||||
}
|
||||
[Fact]
|
||||
public void ToSByte() {
|
||||
var data = new List<object>();
|
||||
data.Add(select.Where(a => Convert.ToSByte(a.Clicks) > 0).ToList());
|
||||
}
|
||||
[Fact]
|
||||
public void ToSingle() {
|
||||
var data = new List<object>();
|
||||
data.Add(select.Where(a => Convert.ToSingle(a.Clicks) > 0).ToList());
|
||||
}
|
||||
[Fact]
|
||||
public void this_ToString() {
|
||||
var data = new List<object>();
|
||||
data.Add(select.Where(a => Convert.ToString(a.Clicks).Equals("")).ToList());
|
||||
}
|
||||
[Fact]
|
||||
public void ToUInt16() {
|
||||
var data = new List<object>();
|
||||
data.Add(select.Where(a => Convert.ToUInt16(a.Clicks) > 0).ToList());
|
||||
}
|
||||
[Fact]
|
||||
public void ToUInt32() {
|
||||
var data = new List<object>();
|
||||
data.Add(select.Where(a => Convert.ToUInt32(a.Clicks) > 0).ToList());
|
||||
}
|
||||
[Fact]
|
||||
public void ToUInt64() {
|
||||
var data = new List<object>();
|
||||
data.Add(select.Where(a => Convert.ToUInt64(a.Clicks) > 0).ToList());
|
||||
}
|
||||
}
|
||||
}
|
622
FreeSql.Tests/Oracle/OracleExpression/DateTimeTest.cs
Normal file
622
FreeSql.Tests/Oracle/OracleExpression/DateTimeTest.cs
Normal file
@ -0,0 +1,622 @@
|
||||
using FreeSql.DataAnnotations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Xunit;
|
||||
|
||||
namespace FreeSql.Tests.OracleExpression {
|
||||
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 TestTypeInfoGuid { get; set; }
|
||||
public TestTypeInfo Type { get; set; }
|
||||
public string Title { get; set; }
|
||||
public DateTime CreateTime { get; set; }
|
||||
}
|
||||
[Table(Name = "TestTypeInfo333")]
|
||||
class TestTypeInfo {
|
||||
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; }
|
||||
}
|
||||
[Table(Name = "TestTypeParentInfo23123")]
|
||||
class TestTypeParentInfo {
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
public List<TestTypeInfo> Types { get; set; }
|
||||
public DateTime Time2 { get; set; }
|
||||
}
|
||||
[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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||
//FROM `tb_topic111333` a
|
||||
//WHERE (((timestampdiff(microsecond, now(), a.`CreateTime`)) / 1000000) > 0);
|
||||
|
||||
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` 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, now(), a__Type.`Time`)) / 1000000) > 0);
|
||||
|
||||
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` 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, now(), a__Type__Parent.`Time2`)) / 1000000) > 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` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||
//FROM `tb_topic111333` a
|
||||
//WHERE (date_sub(a.`CreateTime`, interval ((1 * 86400000000)) microsecond) > a.`CreateTime`);
|
||||
|
||||
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` 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_sub(a__Type.`Time`, interval ((1 * 86400000000)) microsecond) > a.`CreateTime`);
|
||||
|
||||
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` 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_sub(a__Type__Parent.`Time2`, interval ((1 * 86400000000)) microsecond) > 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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 this_ToString() {
|
||||
var data = new List<object>();
|
||||
data.Add(select.Where(a => a.CreateTime.ToString().Equals(DateTime.Now)).ToList());
|
||||
data.Add(select.Where(a => a.Type.Time.AddYears(1).ToString().Equals(DateTime.Now)).ToList());
|
||||
data.Add(select.Where(a => a.Type.Parent.Time2.AddYears(1).ToString().Equals(DateTime.Now)).ToList());
|
||||
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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()))
|
||||
}
|
||||
|
||||
[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.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||
//FROM `tb_topic111333` a
|
||||
//WHERE (((a.`CreateTime`) - (now())) = 0);
|
||||
|
||||
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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())
|
||||
}
|
||||
}
|
||||
}
|
132
FreeSql.Tests/Oracle/OracleExpression/MathTest.cs
Normal file
132
FreeSql.Tests/Oracle/OracleExpression/MathTest.cs
Normal file
@ -0,0 +1,132 @@
|
||||
using FreeSql.DataAnnotations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Xunit;
|
||||
|
||||
namespace FreeSql.Tests.OracleExpression {
|
||||
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 TestTypeInfoGuid { 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());
|
||||
}
|
||||
}
|
||||
}
|
80
FreeSql.Tests/Oracle/OracleExpression/OtherTest.cs
Normal file
80
FreeSql.Tests/Oracle/OracleExpression/OtherTest.cs
Normal file
@ -0,0 +1,80 @@
|
||||
using FreeSql.DataAnnotations;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Xunit;
|
||||
|
||||
namespace FreeSql.Tests.OracleExpression {
|
||||
public class OtherTest {
|
||||
|
||||
ISelect<TableAllType> select => g.oracle.Select<TableAllType>();
|
||||
|
||||
public OtherTest() {
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void Array() {
|
||||
//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();
|
||||
}
|
||||
|
||||
[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 }
|
||||
}
|
||||
}
|
683
FreeSql.Tests/Oracle/OracleExpression/StringTest.cs
Normal file
683
FreeSql.Tests/Oracle/OracleExpression/StringTest.cs
Normal file
@ -0,0 +1,683 @@
|
||||
using FreeSql.DataAnnotations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Xunit;
|
||||
|
||||
namespace FreeSql.Tests.OracleExpression {
|
||||
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 TestTypeInfoGuid { 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 Empty() {
|
||||
var data = new List<object>();
|
||||
data.Add(select.Where(a => (a.Title ?? "") == string.Empty).ToSql());
|
||||
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||
//FROM `tb_topic` a
|
||||
//WHERE((a.`Title`) LIKE '%aaa')
|
||||
|
||||
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||
//FROM `tb_topic` a
|
||||
//WHERE((a.`Title`) LIKE 'aaa%')
|
||||
|
||||
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||
//FROM `tb_topic` a
|
||||
//WHERE((a.`Title`) LIKE '%aaa%')
|
||||
|
||||
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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 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.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||
//FROM `tb_topic` a
|
||||
//WHERE(lower(a.`Title`) = 'aaa');
|
||||
|
||||
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||
//FROM `tb_topic` a
|
||||
//WHERE (upper(a.`Title`) = 'aaa');
|
||||
|
||||
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||
//FROM `tb_topic` a
|
||||
//WHERE (trim(a.`Title`) = 'aaa');
|
||||
|
||||
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||
//FROM `tb_topic` a
|
||||
//WHERE (ltrim(a.`Title`) = 'aaa');
|
||||
|
||||
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||
//FROM `tb_topic` a
|
||||
//WHERE (rtrim(a.`Title`) = 'aaa');
|
||||
|
||||
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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) == false).ToList());
|
||||
data.Add(select.Where(a => !string.IsNullOrEmpty(a.Title)).ToList());
|
||||
}
|
||||
}
|
||||
}
|
260
FreeSql.Tests/Oracle/OracleExpression/TimeSpanTest.cs
Normal file
260
FreeSql.Tests/Oracle/OracleExpression/TimeSpanTest.cs
Normal file
@ -0,0 +1,260 @@
|
||||
using FreeSql.DataAnnotations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Xunit;
|
||||
|
||||
namespace FreeSql.Tests.OracleExpression {
|
||||
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 TestTypeInfoGuid { 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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.`TestTypeInfoGuid` 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)
|
||||
}
|
||||
}
|
||||
}
|
@ -1,14 +1,6 @@
|
||||
using FreeSql.DataAnnotations;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Npgsql;
|
||||
using Npgsql.LegacyPostgis;
|
||||
using NpgsqlTypes;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
using Xunit;
|
||||
|
||||
namespace FreeSql.Tests.SqlServerExpression {
|
||||
@ -17,7 +9,6 @@ namespace FreeSql.Tests.SqlServerExpression {
|
||||
ISelect<TableAllType> select => g.sqlserver.Select<TableAllType>();
|
||||
|
||||
public OtherTest() {
|
||||
NpgsqlConnection.GlobalTypeMapper.UseLegacyPostgis();
|
||||
}
|
||||
|
||||
|
||||
|
@ -434,6 +434,7 @@ namespace FreeSql.Internal {
|
||||
}
|
||||
if (right == "NULL") tryoper = tryoper == "=" ? " IS " : " IS NOT ";
|
||||
if (tryoper == "+" && (expBinary.Left.Type.FullName == "System.String" || expBinary.Right.Type.FullName == "System.String")) return _common.StringConcat(left, right, expBinary.Left.Type, expBinary.Right.Type);
|
||||
if (tryoper == "%") return _common.Mod(left, right, expBinary.Left.Type, expBinary.Right.Type);
|
||||
return $"{left} {tryoper} {right}";
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@ namespace FreeSql.Internal {
|
||||
internal abstract string QuoteParamterName(string name);
|
||||
internal abstract string IsNull(string sql, object value);
|
||||
internal abstract string StringConcat(string left, string right, Type leftType, Type rightType);
|
||||
internal abstract string Mod(string left, string right, Type leftType, Type rightType);
|
||||
internal abstract string QuoteWriteParamter(Type type, string paramterName);
|
||||
internal abstract string QuoteReadColumn(Type type, string columnName);
|
||||
|
||||
|
@ -48,7 +48,7 @@ namespace FreeSql.MySql {
|
||||
internal override string QuoteParamterName(string name) => $"?{(_orm.CodeFirst.IsSyncStructureToLower ? name.ToLower() : name)}";
|
||||
internal override string IsNull(string sql, object value) => $"ifnull({sql}, {value})";
|
||||
internal override string StringConcat(string left, string right, Type leftType, Type rightType) => $"concat({left}, {right})";
|
||||
|
||||
internal override string Mod(string left, string right, Type leftType, Type rightType) => $"{left} % {right}";
|
||||
internal override string QuoteWriteParamter(Type type, string paramterName) {
|
||||
switch (type.FullName) {
|
||||
case "MygisPoint":
|
||||
|
@ -19,41 +19,47 @@ namespace FreeSql.Oracle.Curd {
|
||||
public override string ToSql() {
|
||||
if (_source == null || _source.Any() == false) return null;
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("INSERT INTO ").Append(_commonUtils.QuoteSqlName(_table.DbName)).Append("(");
|
||||
var colidx = 0;
|
||||
var colidxAndIdent = 0;
|
||||
foreach (var col in _table.Columns.Values)
|
||||
if (_ignore.ContainsKey(col.Attribute.Name) == false) {
|
||||
if (colidxAndIdent > 0) sb.Append(", ");
|
||||
sb.Append(_commonUtils.QuoteSqlName(col.Attribute.Name));
|
||||
if (col.Attribute.IsIdentity == false) ++colidx;
|
||||
++colidxAndIdent;
|
||||
}
|
||||
sb.Append(") VALUES");
|
||||
sb.Append("INSERT ");
|
||||
if (_source.Count > 1) sb.Append("ALL");
|
||||
|
||||
_identCol = null;
|
||||
var sbtb = new StringBuilder();
|
||||
sbtb.Append("INTO ");
|
||||
sbtb.Append(_commonUtils.QuoteSqlName(_table.DbName)).Append("(");
|
||||
var colidx = 0;
|
||||
foreach (var col in _table.Columns.Values) {
|
||||
if (col.Attribute.IsIdentity) {
|
||||
_identCol = col;
|
||||
continue;
|
||||
}
|
||||
if (col.Attribute.IsIdentity == false && _ignore.ContainsKey(col.Attribute.Name) == false) {
|
||||
if (colidx > 0) sbtb.Append(", ");
|
||||
sbtb.Append(_commonUtils.QuoteSqlName(col.Attribute.Name));
|
||||
++colidx;
|
||||
}
|
||||
}
|
||||
sbtb.Append(") ");
|
||||
|
||||
_params = new DbParameter[colidx * _source.Count];
|
||||
var didx = 0;
|
||||
foreach (var d in _source) {
|
||||
if (didx > 0) sb.Append(", ");
|
||||
if (_source.Count > 1) sb.Append("\r\n");
|
||||
sb.Append(sbtb);
|
||||
sb.Append("VALUES");
|
||||
sb.Append("(");
|
||||
var colidx2 = 0;
|
||||
var colidx2AndIdent = 0;
|
||||
foreach (var col in _table.Columns.Values)
|
||||
if (_ignore.ContainsKey(col.Attribute.Name) == false) {
|
||||
if (colidx2AndIdent > 0) sb.Append(", ");
|
||||
if (col.Attribute.IsIdentity) {
|
||||
sb.Append(_commonUtils.QuoteSqlName($"{Utils.GetCsName(_table.DbName)}_seq_{col.Attribute.Name}")).Append(".nextval");
|
||||
_identCol = col;
|
||||
} else {
|
||||
foreach (var col in _table.Columns.Values) {
|
||||
if (col.Attribute.IsIdentity == false && _ignore.ContainsKey(col.Attribute.Name) == false) {
|
||||
if (colidx2 > 0) sb.Append(", ");
|
||||
sb.Append(_commonUtils.QuoteWriteParamter(col.CsType, $"{_commonUtils.QuoteParamterName(col.CsName)}{didx}"));
|
||||
_params[didx * colidx + colidx2] = _commonUtils.AppendParamter(null, $"{col.CsName}{didx}", col.CsType, _table.Properties.TryGetValue(col.CsName, out var tryp) ? tryp.GetValue(d) : null);
|
||||
++colidx2;
|
||||
}
|
||||
++colidx2AndIdent;
|
||||
}
|
||||
sb.Append(")");
|
||||
++didx;
|
||||
}
|
||||
if (_source.Count > 1) sb.Append("\r\n SELECT 1 FROM DUAL");
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
@ -62,7 +68,7 @@ namespace FreeSql.Oracle.Curd {
|
||||
var sql = this.ToSql();
|
||||
if (string.IsNullOrEmpty(sql)) return 0;
|
||||
|
||||
if (_identCol == null) {
|
||||
if (_identCol == null || _source.Count > 1) {
|
||||
_orm.Ado.ExecuteNonQuery(CommandType.Text, sql, _params);
|
||||
return 0;
|
||||
}
|
||||
@ -76,7 +82,7 @@ namespace FreeSql.Oracle.Curd {
|
||||
var sql = this.ToSql();
|
||||
if (string.IsNullOrEmpty(sql)) return 0;
|
||||
|
||||
if (_identCol == null) {
|
||||
if (_identCol == null || _source.Count > 1) {
|
||||
await _orm.Ado.ExecuteNonQueryAsync(CommandType.Text, sql, _params);
|
||||
return 0;
|
||||
}
|
||||
|
@ -35,13 +35,13 @@ namespace FreeSql.Oracle {
|
||||
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
||||
return param;
|
||||
else if (param is DateTime)
|
||||
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss"), "'");
|
||||
return string.Concat("to_timestamp('", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.ffffff"), "','YYYY-MM-DD HH24:MI:SS.FF6)");
|
||||
else if (param is DateTime?)
|
||||
return string.Concat("'", (param as DateTime?).Value.ToString("yyyy-MM-dd HH:mm:ss"), "'");
|
||||
return string.Concat("to_timestamp('", (param as DateTime?).Value.ToString("yyyy-MM-dd HH:mm:ss.ffffff"), "','YYYY-MM-DD HH24:MI:SS.FF6)");
|
||||
else if (param is TimeSpan)
|
||||
return ((TimeSpan)param).Ticks / 10;
|
||||
return $"numtodsinterval({((TimeSpan)param).Ticks * 1.0 / 10000000},'second')";
|
||||
else if (param is TimeSpan?)
|
||||
return (param as TimeSpan?).Value.Ticks / 10;
|
||||
return $"numtodsinterval({(param as TimeSpan?).Value.Ticks * 1.0 / 10000000},'second')";
|
||||
else if (param is IEnumerable) {
|
||||
var sb = new StringBuilder();
|
||||
var ie = param as IEnumerable;
|
||||
|
@ -146,7 +146,7 @@ namespace FreeSql.Oracle {
|
||||
public static bool Ping(this DbConnection that) {
|
||||
try {
|
||||
var cmd = that.CreateCommand();
|
||||
cmd.CommandText = "select 1";
|
||||
cmd.CommandText = "select 1 from dual";
|
||||
cmd.ExecuteNonQuery();
|
||||
return true;
|
||||
} catch {
|
||||
|
@ -29,17 +29,17 @@ namespace FreeSql.Oracle {
|
||||
static Dictionary<string, (OracleDbType type, string dbtype, string dbtypeFull, bool? isUnsigned, bool? isnullable, object defaultValue)> _dicCsToDb = new Dictionary<string, (OracleDbType type, string dbtype, string dbtypeFull, bool? isUnsigned, bool? isnullable, object defaultValue)>() {
|
||||
{ typeof(bool).FullName, (OracleDbType.Boolean, "number","number(1) NOT NULL", null, false, false) },{ typeof(bool?).FullName, (OracleDbType.Boolean, "number","number(1) NULL", null, true, null) },
|
||||
|
||||
{ typeof(sbyte).FullName, (OracleDbType.Byte, "number", "number(4) NOT NULL", false, false, 0) },{ typeof(sbyte?).FullName, (OracleDbType.Byte, "number", "number(4) NULL", false, true, null) },
|
||||
{ typeof(short).FullName, (OracleDbType.Int16, "number","number(4) NOT NULL", false, false, 0) },{ typeof(short?).FullName, (OracleDbType.Int16, "number", "number(4) NULL", false, true, null) },
|
||||
{ typeof(int).FullName, (OracleDbType.Int32, "number", "number(8) NOT NULL", false, false, 0) },{ typeof(int?).FullName, (OracleDbType.Int32, "number", "number(8) NULL", false, true, null) },
|
||||
{ typeof(long).FullName, (OracleDbType.Int64, "number","number(16) NOT NULL", false, false, 0) },{ typeof(long?).FullName, (OracleDbType.Int64, "bigint","bigint(16) NULL", false, true, null) },
|
||||
{ typeof(sbyte).FullName, (OracleDbType.Decimal, "number", "number(4) NOT NULL", false, false, 0) },{ typeof(sbyte?).FullName, (OracleDbType.Decimal, "number", "number(4) NULL", false, true, null) },
|
||||
{ typeof(short).FullName, (OracleDbType.Int16, "number","number(6) NOT NULL", false, false, 0) },{ typeof(short?).FullName, (OracleDbType.Int16, "number", "number(6) NULL", false, true, null) },
|
||||
{ typeof(int).FullName, (OracleDbType.Int32, "number", "number(11) NOT NULL", false, false, 0) },{ typeof(int?).FullName, (OracleDbType.Int32, "number", "number(11) NULL", false, true, null) },
|
||||
{ typeof(long).FullName, (OracleDbType.Int64, "number","number(21) NOT NULL", false, false, 0) },{ typeof(long?).FullName, (OracleDbType.Int64, "number","number(21) NULL", false, true, null) },
|
||||
|
||||
{ typeof(byte).FullName, (OracleDbType.Byte, "number","number(2) NOT NULL", true, false, 0) },{ typeof(byte?).FullName, (OracleDbType.Byte, "number","number(2) NULL", true, true, null) },
|
||||
{ typeof(ushort).FullName, (OracleDbType.Int16, "number","number(8) NOT NULL", true, false, 0) },{ typeof(ushort?).FullName, (OracleDbType.Int16, "number", "number(8) NULL", true, true, null) },
|
||||
{ typeof(uint).FullName, (OracleDbType.Int32, "number", "number(16) NOT NULL", true, false, 0) },{ typeof(uint?).FullName, (OracleDbType.Int32, "number", "number(16) NULL", true, true, null) },
|
||||
{ typeof(ulong).FullName, (OracleDbType.Int64, "number", "number(32) NOT NULL", true, false, 0) },{ typeof(ulong?).FullName, (OracleDbType.Int64, "number", "number(32) NULL", true, true, null) },
|
||||
{ typeof(byte).FullName, (OracleDbType.Byte, "number","number(3) NOT NULL", true, false, 0) },{ typeof(byte?).FullName, (OracleDbType.Byte, "number","number(3) NULL", true, true, null) },
|
||||
{ typeof(ushort).FullName, (OracleDbType.Decimal, "number","number(5) NOT NULL", true, false, 0) },{ typeof(ushort?).FullName, (OracleDbType.Decimal, "number", "number(5) NULL", true, true, null) },
|
||||
{ typeof(uint).FullName, (OracleDbType.Decimal, "number", "number(10) NOT NULL", true, false, 0) },{ typeof(uint?).FullName, (OracleDbType.Decimal, "number", "number(10) NULL", true, true, null) },
|
||||
{ typeof(ulong).FullName, (OracleDbType.Decimal, "number", "number(20) NOT NULL", true, false, 0) },{ typeof(ulong?).FullName, (OracleDbType.Decimal, "number", "number(20) NULL", true, true, null) },
|
||||
|
||||
{ typeof(double).FullName, (OracleDbType.Double, "double", "double(126) NOT NULL", false, false, 0) },{ typeof(double?).FullName, (OracleDbType.Double, "double", "double(126) NULL", false, true, null) },
|
||||
{ typeof(double).FullName, (OracleDbType.Double, "float", "float(126) NOT NULL", false, false, 0) },{ typeof(double?).FullName, (OracleDbType.Double, "float", "float(126) NULL", false, true, null) },
|
||||
{ typeof(float).FullName, (OracleDbType.Single, "float","float(63) NOT NULL", false, false, 0) },{ typeof(float?).FullName, (OracleDbType.Single, "float","float(63) NULL", false, true, null) },
|
||||
{ typeof(decimal).FullName, (OracleDbType.Decimal, "number", "number(10,2) NOT NULL", false, false, 0) },{ typeof(decimal?).FullName, (OracleDbType.Decimal, "number", "number(10,2) NULL", false, true, null) },
|
||||
|
||||
@ -47,10 +47,10 @@ namespace FreeSql.Oracle {
|
||||
{ typeof(DateTime).FullName, (OracleDbType.TimeStamp, "timestamp", "timestamp(6) NOT NULL", false, false, new DateTime(1970,1,1)) },{ typeof(DateTime?).FullName, (OracleDbType.TimeStamp, "timestamp", "timestamp(6) NULL", false, true, null) },
|
||||
{ typeof(DateTimeOffset).FullName, (OracleDbType.TimeStampLTZ, "timestamp with local time zone", "timestamp(6) with local time zone NOT NULL", false, false, new DateTime(1970,1,1)) },{ typeof(DateTimeOffset?).FullName, (OracleDbType.TimeStampLTZ, "timestamp with local time zone", "timestamp(6) with local time zone NULL", false, true, null) },
|
||||
|
||||
{ typeof(byte[]).FullName, (OracleDbType.Blob, "blog", "blog(4000) NULL", false, null, new byte[0]) },
|
||||
{ typeof(byte[]).FullName, (OracleDbType.Blob, "blob", "blob NULL", false, null, new byte[0]) },
|
||||
{ typeof(string).FullName, (OracleDbType.NVarchar2, "nvarchar2", "nvarchar2(255) NULL", false, null, "") },
|
||||
|
||||
{ typeof(Guid).FullName, (OracleDbType.Char, "char", "char(36 BYTE) NOT NULL", false, false, Guid.Empty) },{ typeof(Guid?).FullName, (OracleDbType.Char, "char", "char(36 BYTE) NULL", false, true, null) },
|
||||
{ typeof(Guid).FullName, (OracleDbType.Char, "char", "char(36 CHAR) NOT NULL", false, false, Guid.Empty) },{ typeof(Guid?).FullName, (OracleDbType.Char, "char", "char(36 CHAR) NULL", false, true, null) },
|
||||
};
|
||||
|
||||
public (int type, string dbtype, string dbtypeFull, bool? isnullable, object defaultValue)? GetDbInfo(Type type) {
|
||||
@ -142,17 +142,15 @@ from all_tab_columns
|
||||
where owner={{0}} and table_name={{1}}".FormatOracleSQL(tboldname ?? tbname);
|
||||
var ds = _orm.Ado.ExecuteArray(CommandType.Text, sql);
|
||||
var tbstruct = ds.ToDictionary(a => string.Concat(a[0]), a => {
|
||||
var sqlType = string.Concat(a[1]);
|
||||
var sqlType = string.Concat(a[1]).ToUpper();
|
||||
var data_length = long.Parse(string.Concat(a[2]));
|
||||
long.TryParse(string.Concat(a[3]), out var data_precision);
|
||||
long.TryParse(string.Concat(a[4]), out var data_scale);
|
||||
var char_used = string.Concat(a[5]);
|
||||
switch(sqlType.ToUpper()) {
|
||||
case "CHAR": data_length /= char_used.ToLower() == "c" ? 4 : 2; break;
|
||||
}
|
||||
if (Regex.IsMatch(sqlType, @"INTERVAL DAY\(\d+\) TO SECOND\(\d+\)", RegexOptions.IgnoreCase)) {
|
||||
} else if (Regex.IsMatch(sqlType, @"INTERVAL YEAR\(\d+\) TO MONTH", RegexOptions.IgnoreCase)) {
|
||||
} else if (sqlType.StartsWith("TIMESTAMP", StringComparison.CurrentCultureIgnoreCase)) {
|
||||
} else if (sqlType.StartsWith("BLOB")) {
|
||||
} else if (char_used.ToLower() == "c")
|
||||
sqlType += sqlType.StartsWith("N") ? $"({data_length / 2})" : $"({data_length / 4} CHAR)";
|
||||
else if (char_used.ToLower() == "b")
|
||||
@ -196,7 +194,7 @@ where owner={{0}} and table_name={{1}}".FormatOracleSQL(tboldname ?? tbname);
|
||||
//添加列
|
||||
sbalter.Append("execute immediate 'ALTER TABLE ").Append(_commonUtils.QuoteSqlName($"{tbname[0]}.{tbname[1]}")).Append(" ADD (").Append(_commonUtils.QuoteSqlName(tbcol.Attribute.Name)).Append(" ").Append(dbtypeNoneNotNull).Append(")';\r\n");
|
||||
if (tbcol.Attribute.IsNullable == false) {
|
||||
sbalter.Append("execute immediate 'UPDATE ").Append(_commonUtils.QuoteSqlName($"{tbname[0]}.{tbname[1]}")).Append(" SET ").Append(_commonUtils.QuoteSqlName(tbcol.Attribute.Name)).Append(_commonUtils.FormatSql(" = {0}';\r\n", tbcol.Attribute.DbDefautValue).Replace("'", "''"));
|
||||
sbalter.Append("execute immediate 'UPDATE ").Append(_commonUtils.QuoteSqlName($"{tbname[0]}.{tbname[1]}")).Append(" SET ").Append(_commonUtils.QuoteSqlName(tbcol.Attribute.Name)).Append(_commonUtils.FormatSql(" = {0}", tbcol.Attribute.DbDefautValue).Replace("'", "''")).Append("';\r\n");
|
||||
sbalter.Append("execute immediate 'ALTER TABLE ").Append(_commonUtils.QuoteSqlName($"{tbname[0]}.{tbname[1]}")).Append(" MODIFY ").Append(_commonUtils.QuoteSqlName(tbcol.Attribute.Name)).Append(" NOT NULL';\r\n");
|
||||
}
|
||||
if (tbcol.Attribute.IsIdentity) seqcols.Add((tbcol, tbname, tbcol.Attribute.IsIdentity));
|
||||
@ -250,22 +248,43 @@ where owner={{0}} and table_name={{1}}".FormatOracleSQL(tboldname ?? tbname);
|
||||
sb.Append("execute immediate 'DROP TABLE ").Append(tablename).Append("';\r\n");
|
||||
sb.Append("execute immediate 'ALTER TABLE ").Append(tmptablename).Append(" RENAME TO ").Append(_commonUtils.QuoteSqlName($"{tbname[1]}")).Append("';\r\n");
|
||||
}
|
||||
Dictionary<string, bool> dicDeclare = new Dictionary<string, bool>();
|
||||
foreach (var seqcol in seqcols) {
|
||||
var tbname = seqcol.Item2;
|
||||
var seqname = Utils.GetCsName($"{tbname[1]}_seq_{seqcol.Item1.Attribute.Name}");
|
||||
var tiggerName = seqname + "TI";
|
||||
var tbname2 = _commonUtils.QuoteSqlName($"{tbname[0]}.{tbname[1]}");
|
||||
var colname2 = _commonUtils.QuoteSqlName(seqcol.Item1.Attribute.Name);
|
||||
sbDeclare.Append("declare ").Append(seqname).Append("_exists NUMBER; \r\n");
|
||||
if (dicDeclare.ContainsKey(seqname) == false) {
|
||||
sbDeclare.Append("\r\n").Append(seqname).Append("_exists NUMBER; \r\n");
|
||||
dicDeclare.Add(seqname, true);
|
||||
}
|
||||
sb.Append(seqname).Append("_exists := 0; \r\n")
|
||||
.Append(" select count(1) into ").Append(seqname).Append("_exists from user_sequences where sequence_name={0}; \r\n".FormatOracleSQL(seqname))
|
||||
.Append("if ").Append(seqname).Append("_exists > 0 then \r\n")
|
||||
.Append(" execute immediate 'DROP SEQUENCE ").Append(_commonUtils.QuoteSqlName(seqname)).Append("';\r\n")
|
||||
.Append("end if; \r\n");
|
||||
if (seqcol.Item3) {
|
||||
var startWith = _orm.Ado.ExecuteScalar(CommandType.Text, $" select nvl(max({colname2})+1,1) from {tbname2}");
|
||||
var startWith = _orm.Ado.ExecuteScalar(CommandType.Text, " select 1 from all_tab_comments where owner={0} and table_name={1}".FormatOracleSQL(tbname)) == null ? 1 :
|
||||
_orm.Ado.ExecuteScalar(CommandType.Text, $" select nvl(max({colname2})+1,1) from {tbname2}");
|
||||
sb.Append("execute immediate 'CREATE SEQUENCE ").Append(_commonUtils.QuoteSqlName(seqname)).Append(" start with ").Append(startWith).Append("';\r\n");
|
||||
sb.Append("execute immediate 'CREATE OR REPLACE TRIGGER ").Append(_commonUtils.QuoteSqlName(tiggerName))
|
||||
.Append(" \r\nbefore insert on ").Append(tbname2)
|
||||
.Append(" \r\nfor each row \r\nbegin\r\nselect ").Append(_commonUtils.QuoteSqlName(seqname))
|
||||
.Append(".nextval into :new.").Append(colname2).Append(" from dual;\r\nend;';\r\n");
|
||||
} else {
|
||||
if (dicDeclare.ContainsKey(tiggerName) == false) {
|
||||
sbDeclare.Append("\r\n").Append(tiggerName).Append("_exists NUMBER; \r\n");
|
||||
dicDeclare.Add(tiggerName, true);
|
||||
}
|
||||
sb.Append(tiggerName).Append("_exists := 0; \r\n")
|
||||
.Append(" select count(1) into ").Append(tiggerName).Append("_exists from user_triggers where trigger_name={0}; \r\n".FormatOracleSQL(tiggerName))
|
||||
.Append("if ").Append(tiggerName).Append("_exists > 0 then \r\n")
|
||||
.Append(" execute immediate 'DROP TRIGGER ").Append(_commonUtils.QuoteSqlName(tiggerName)).Append("';\r\n")
|
||||
.Append("end if; \r\n");
|
||||
}
|
||||
}
|
||||
if (sbDeclare.Length > 0) sbDeclare.Insert(0, "declare ");
|
||||
return sb.Length == 0 ? null : sb.Insert(0, "BEGIN \r\n").Insert(0, sbDeclare.ToString()).Append("END;").ToString();
|
||||
}
|
||||
|
||||
|
@ -60,60 +60,60 @@ namespace FreeSql.Oracle {
|
||||
}
|
||||
var left = ExpressionLambdaToSql(exp.Expression, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName);
|
||||
switch (exp.Member.Name) {
|
||||
case "Length": return $"char_length({left})";
|
||||
case "Length": return $"length({left})";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
internal override string ExpressionLambdaToSqlMemberAccessDateTime(MemberExpression exp, List<SelectTableInfo> _tables, List<SelectColumnInfo> _selectColumnMap, Func<Expression[], string> getSelectGroupingMapString, SelectTableInfoType tbtype, bool isQuoteName) {
|
||||
if (exp.Expression == null) {
|
||||
switch (exp.Member.Name) {
|
||||
case "Now": return "now()";
|
||||
case "UtcNow": return "utc_timestamp()";
|
||||
case "Today": return "curdate()";
|
||||
case "MinValue": return "cast('0001/1/1 0:00:00' as datetime)";
|
||||
case "MaxValue": return "cast('9999/12/31 23:59:59' as datetime)";
|
||||
case "Now": return "systimestamp";
|
||||
case "UtcNow": return "sys_extract_utc(systimestamp)";
|
||||
case "Today": return "trunc(systimestamp)";
|
||||
case "MinValue": return "to_timestamp('0001-01-01 00:00:00','YYYY-MM-DD HH24:MI:SS.FF6')";
|
||||
case "MaxValue": return "to_timestamp('9999-12-31 23:59:59','YYYY-MM-DD HH24:MI:SS.FF6')";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
var left = ExpressionLambdaToSql(exp.Expression, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName);
|
||||
switch (exp.Member.Name) {
|
||||
case "Date": return $"cast(date_format({left},'%Y-%m-%d') as datetime)";
|
||||
case "TimeOfDay": return $"timestampdiff(microsecond, date_format({left},'%Y-%m-%d'), {left})";
|
||||
case "DayOfWeek": return $"(dayofweek({left})-1)";
|
||||
case "Day": return $"dayofmonth({left})";
|
||||
case "DayOfYear": return $"dayofyear({left})";
|
||||
case "Month": return $"month({left})";
|
||||
case "Year": return $"year({left})";
|
||||
case "Hour": return $"hour({left})";
|
||||
case "Minute": return $"minute({left})";
|
||||
case "Second": return $"second({left})";
|
||||
case "Millisecond": return $"floor(microsecond({left})/1000)";
|
||||
case "Ticks": return $"(timestampdiff(microsecond, '0001-1-1', {left})*10)";
|
||||
case "Date": return $"trunc({left})";
|
||||
case "TimeOfDay": return $"({left}-trunc({left}))";
|
||||
case "DayOfWeek": return $"case when to_char({left})='7' then 0 else cast(to_char({left}) as number) end";
|
||||
case "Day": return $"cast(to_char({left},'DD') as number)";
|
||||
case "DayOfYear": return $"cast(to_char({left},'DDD') as number)";
|
||||
case "Month": return $"cast(to_char({left},'MM') as number)";
|
||||
case "Year": return $"cast(to_char({left},'YYYY') as number)";
|
||||
case "Hour": return $"cast(to_char({left},'HH24') as number)";
|
||||
case "Minute": return $"cast(to_char({left},'MI') as number)";
|
||||
case "Second": return $"cast(to_char({left},'SS') as number)";
|
||||
case "Millisecond": return $"cast(to_char({left},'FF3') as number)";
|
||||
case "Ticks": return $"cast(to_char({left},'FF7') as number)";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
internal override string ExpressionLambdaToSqlMemberAccessTimeSpan(MemberExpression exp, List<SelectTableInfo> _tables, List<SelectColumnInfo> _selectColumnMap, Func<Expression[], string> getSelectGroupingMapString, SelectTableInfoType tbtype, bool isQuoteName) {
|
||||
if (exp.Expression == null) {
|
||||
switch (exp.Member.Name) {
|
||||
case "Zero": return "0";
|
||||
case "MinValue": return "-922337203685477580"; //微秒 Ticks / 10
|
||||
case "MaxValue": return "922337203685477580";
|
||||
case "Zero": return "numtodsinterval(0,'second')";
|
||||
case "MinValue": return "numtodsinterval(-233720368.5477580,'second')";
|
||||
case "MaxValue": return "numtodsinterval(233720368.5477580,'second')";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
var left = ExpressionLambdaToSql(exp.Expression, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName);
|
||||
switch (exp.Member.Name) {
|
||||
case "Days": return $"(({left}) div {(long)1000000 * 60 * 60 * 24})";
|
||||
case "Hours": return $"(({left}) div {(long)1000000 * 60 * 60} mod 24)";
|
||||
case "Milliseconds": return $"(({left}) div 1000 mod 1000)";
|
||||
case "Minutes": return $"(({left}) div {(long)1000000 * 60} mod 60)";
|
||||
case "Seconds": return $"(({left}) div 1000000 mod 60)";
|
||||
case "Ticks": return $"(({left}) * 10)";
|
||||
case "TotalDays": return $"(({left}) / {(long)1000000 * 60 * 60 * 24})";
|
||||
case "TotalHours": return $"(({left}) / {(long)1000000 * 60 * 60})";
|
||||
case "TotalMilliseconds": return $"(({left}) / 1000)";
|
||||
case "TotalMinutes": return $"(({left}) / {(long)1000000 * 60})";
|
||||
case "TotalSeconds": return $"(({left}) / 1000000)";
|
||||
case "Days": return $"extract(day from {left})";
|
||||
case "Hours": return $"extract(hour from {left})";
|
||||
case "Milliseconds": return $"cast(substr(extract(second from {left})-floor(extract(second from {left})),2,3) as number)";
|
||||
case "Minutes": return $"extract(minute from {left})";
|
||||
case "Seconds": return $"floor(extract(second from {left}))";
|
||||
case "Ticks": return $"(extract(day from {left})*86400+extract(hour from {left})*3600+extract(minute from {left})*60+extract(second from {left}))*10000000";
|
||||
case "TotalDays": return $"extract(day from {left})";
|
||||
case "TotalHours": return $"(extract(day from {left})*24+extract(hour from {left}))";
|
||||
case "TotalMilliseconds": return $"(extract(day from {left})*86400+extract(hour from {left})*3600+extract(minute from {left})*60+extract(second from {left}))*1000";
|
||||
case "TotalMinutes": return $"(extract(day from {left})*1440+extract(hour from {left})*60+extract(minute from {left}))";
|
||||
case "TotalSeconds": return $"(extract(day from {left})*86400+extract(hour from {left})*3600+extract(minute from {left})*60+extract(second from {left}))";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -134,10 +134,10 @@ namespace FreeSql.Oracle {
|
||||
case "Contains":
|
||||
var args0Value = getExp(exp.Arguments[0]);
|
||||
if (args0Value == "NULL") return $"({left}) IS NULL";
|
||||
if (exp.Method.Name == "StartsWith") return $"({left}) LIKE {(args0Value.EndsWith("'") ? args0Value.Insert(args0Value.Length - 1, "%") : $"concat({args0Value}, '%')")}";
|
||||
if (exp.Method.Name == "EndsWith") return $"({left}) LIKE {(args0Value.StartsWith("'") ? args0Value.Insert(1, "%") : $"concat('%', {args0Value})")}";
|
||||
if (exp.Method.Name == "StartsWith") return $"({left}) LIKE {(args0Value.EndsWith("'") ? args0Value.Insert(args0Value.Length - 1, "%") : $"(to_char({args0Value})||'%')")}";
|
||||
if (exp.Method.Name == "EndsWith") return $"({left}) LIKE {(args0Value.StartsWith("'") ? args0Value.Insert(1, "%") : $"('%'||to_char({args0Value}))")}";
|
||||
if (args0Value.StartsWith("'") && args0Value.EndsWith("'")) return $"({left}) LIKE {args0Value.Insert(1, "%").Insert(args0Value.Length, "%")}";
|
||||
return $"({left}) LIKE concat('%', {args0Value}, '%')";
|
||||
return $"({left}) LIKE ('%'||to_char({args0Value})||'%')";
|
||||
case "ToLower": return $"lower({left})";
|
||||
case "ToUpper": return $"upper({left})";
|
||||
case "Substring":
|
||||
@ -152,14 +152,14 @@ namespace FreeSql.Oracle {
|
||||
var locateArgs1 = getExp(exp.Arguments[1]);
|
||||
if (long.TryParse(locateArgs1, out var testtrylng2)) locateArgs1 = (testtrylng2 + 1).ToString();
|
||||
else locateArgs1 += "+1";
|
||||
return $"(locate({left}, {indexOfFindStr}, {locateArgs1})-1)";
|
||||
return $"(instr({left}, {indexOfFindStr}, {locateArgs1}, 1)-1)";
|
||||
}
|
||||
return $"(locate({left}, {indexOfFindStr})-1)";
|
||||
return $"(instr({left}, {indexOfFindStr}, 1, 1))-1";
|
||||
case "PadLeft":
|
||||
if (exp.Arguments.Count == 1) return $"lpad({left}, {getExp(exp.Arguments[0])})";
|
||||
if (exp.Arguments.Count == 1) return $"lpad({left}, {getExp(exp.Arguments[0])}, ' ')";
|
||||
return $"lpad({left}, {getExp(exp.Arguments[0])}, {getExp(exp.Arguments[1])})";
|
||||
case "PadRight":
|
||||
if (exp.Arguments.Count == 1) return $"rpad({left}, {getExp(exp.Arguments[0])})";
|
||||
if (exp.Arguments.Count == 1) return $"rpad({left}, {getExp(exp.Arguments[0])}, ' ')";
|
||||
return $"rpad({left}, {getExp(exp.Arguments[0])}, {getExp(exp.Arguments[1])})";
|
||||
case "Trim":
|
||||
case "TrimStart":
|
||||
@ -176,18 +176,18 @@ namespace FreeSql.Oracle {
|
||||
argsTrim01s = arritem.Expressions.ToArray();
|
||||
}
|
||||
foreach (var argsTrim01 in argsTrim01s) {
|
||||
if (exp.Method.Name == "Trim") left = $"trim({getExp(argsTrim01)} from {left})";
|
||||
if (exp.Method.Name == "TrimStart") left = $"trim(leading {getExp(argsTrim01)} from {left})";
|
||||
if (exp.Method.Name == "TrimEnd") left = $"trim(trailing {getExp(argsTrim01)} from {left})";
|
||||
if (exp.Method.Name == "Trim") left = $"trim(both {getExp(argsTrim01)} from {left})";
|
||||
if (exp.Method.Name == "TrimStart") left = $"ltrim({left},{getExp(argsTrim01)})";
|
||||
if (exp.Method.Name == "TrimEnd") left = $"rtrim({left},{getExp(argsTrim01)})";
|
||||
}
|
||||
}
|
||||
return left;
|
||||
case "Replace": return $"replace({left}, {getExp(exp.Arguments[0])}, {getExp(exp.Arguments[1])})";
|
||||
case "CompareTo": return $"strcmp({left}, {getExp(exp.Arguments[0])})";
|
||||
//case "CompareTo": return $"strcmp({left}, {getExp(exp.Arguments[0])})";
|
||||
case "Equals": return $"({left} = {getExp(exp.Arguments[0])})";
|
||||
}
|
||||
}
|
||||
throw new Exception($"MySqlExpression 未现实函数表达式 {exp} 解析");
|
||||
throw new Exception($"OracleExpression 未现实函数表达式 {exp} 解析");
|
||||
}
|
||||
internal override string ExpressionLambdaToSqlCallMath(MethodCallExpression exp, List<SelectTableInfo> _tables, List<SelectColumnInfo> _selectColumnMap, Func<Expression[], string> getSelectGroupingMapString, SelectTableInfoType tbtype, bool isQuoteName) {
|
||||
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName);
|
||||
@ -195,14 +195,15 @@ namespace FreeSql.Oracle {
|
||||
case "Abs": return $"abs({getExp(exp.Arguments[0])})";
|
||||
case "Sign": return $"sign({getExp(exp.Arguments[0])})";
|
||||
case "Floor": return $"floor({getExp(exp.Arguments[0])})";
|
||||
case "Ceiling": return $"ceiling({getExp(exp.Arguments[0])})";
|
||||
case "Ceiling": return $"ceil({getExp(exp.Arguments[0])})";
|
||||
case "Round":
|
||||
if (exp.Arguments.Count > 1 && exp.Arguments[1].Type.FullName == "System.Int32") return $"round({getExp(exp.Arguments[0])}, {getExp(exp.Arguments[1])})";
|
||||
return $"round({getExp(exp.Arguments[0])})";
|
||||
case "Exp": return $"exp({getExp(exp.Arguments[0])})";
|
||||
case "Log": return $"log({getExp(exp.Arguments[0])})";
|
||||
case "Log10": return $"log10({getExp(exp.Arguments[0])})";
|
||||
case "Pow": return $"pow({getExp(exp.Arguments[0])}, {getExp(exp.Arguments[1])})";
|
||||
case "Log": if (exp.Arguments.Count > 1) return $"log({getExp(exp.Arguments[1])},{getExp(exp.Arguments[0])})";
|
||||
return $"log(2.7182818284590451,{getExp(exp.Arguments[0])})";
|
||||
case "Log10": return $"log(10,{getExp(exp.Arguments[0])})";
|
||||
case "Pow": return $"power({getExp(exp.Arguments[0])}, {getExp(exp.Arguments[1])})";
|
||||
case "Sqrt": return $"sqrt({getExp(exp.Arguments[0])})";
|
||||
case "Cos": return $"cos({getExp(exp.Arguments[0])})";
|
||||
case "Sin": return $"sin({getExp(exp.Arguments[0])})";
|
||||
@ -210,70 +211,70 @@ namespace FreeSql.Oracle {
|
||||
case "Acos": return $"acos({getExp(exp.Arguments[0])})";
|
||||
case "Asin": return $"asin({getExp(exp.Arguments[0])})";
|
||||
case "Atan": return $"atan({getExp(exp.Arguments[0])})";
|
||||
case "Atan2": return $"atan2({getExp(exp.Arguments[0])}, {getExp(exp.Arguments[1])})";
|
||||
case "Truncate": return $"truncate({getExp(exp.Arguments[0])}, 0)";
|
||||
//case "Atan2": return $"atan2({getExp(exp.Arguments[0])}, {getExp(exp.Arguments[1])})";
|
||||
case "Truncate": return $"trunc({getExp(exp.Arguments[0])}, 0)";
|
||||
}
|
||||
throw new Exception($"MySqlExpression 未现实函数表达式 {exp} 解析");
|
||||
throw new Exception($"OracleExpression 未现实函数表达式 {exp} 解析");
|
||||
}
|
||||
internal override string ExpressionLambdaToSqlCallDateTime(MethodCallExpression exp, List<SelectTableInfo> _tables, List<SelectColumnInfo> _selectColumnMap, Func<Expression[], string> getSelectGroupingMapString, SelectTableInfoType tbtype, bool isQuoteName) {
|
||||
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName);
|
||||
if (exp.Object == null) {
|
||||
switch (exp.Method.Name) {
|
||||
case "Compare": return $"({getExp(exp.Arguments[0])} - ({getExp(exp.Arguments[1])}))";
|
||||
case "DaysInMonth": return $"dayofmonth(last_day(concat({getExp(exp.Arguments[0])}, '-', {getExp(exp.Arguments[1])}, '-01')))";
|
||||
case "Compare": return $"extract(day from ({getExp(exp.Arguments[0])}-({getExp(exp.Arguments[1])})))";
|
||||
case "DaysInMonth": return $"cast(to_char(last_day(({getExp(exp.Arguments[0])})||'-'||({getExp(exp.Arguments[1])})||'-01'),'DD') as number)";
|
||||
case "Equals": return $"({getExp(exp.Arguments[0])} = {getExp(exp.Arguments[1])})";
|
||||
|
||||
case "IsLeapYear":
|
||||
var isLeapYearArgs1 = getExp(exp.Arguments[0]);
|
||||
return $"(({isLeapYearArgs1})%4=0 AND ({isLeapYearArgs1})%100<>0 OR ({isLeapYearArgs1})%400=0)";
|
||||
return $"(mod({isLeapYearArgs1},4)=0 AND mod({isLeapYearArgs1},100)<>0 OR mod({isLeapYearArgs1},400)=0)";
|
||||
|
||||
case "Parse": return $"cast({getExp(exp.Arguments[0])} as datetime)";
|
||||
case "Parse": return $"to_timestamp({getExp(exp.Arguments[0])},'YYYY-MM-DD HH24:MI:SS.FF6')";
|
||||
case "ParseExact":
|
||||
case "TryParse":
|
||||
case "TryParseExact": return $"cast({getExp(exp.Arguments[0])} as datetime)";
|
||||
case "TryParseExact": return $"to_timestamp({getExp(exp.Arguments[0])},'YYYY-MM-DD HH24:MI:SS.FF6')";
|
||||
}
|
||||
} else {
|
||||
var left = getExp(exp.Object);
|
||||
var args1 = exp.Arguments.Count == 0 ? null : getExp(exp.Arguments[0]);
|
||||
switch (exp.Method.Name) {
|
||||
case "Add": return $"date_add({left}, interval ({args1}) microsecond)";
|
||||
case "AddDays": return $"date_add({left}, interval ({args1}) day)";
|
||||
case "AddHours": return $"date_add({left}, interval ({args1}) hour)";
|
||||
case "AddMilliseconds": return $"date_add({left}, interval ({args1})*1000 microsecond)";
|
||||
case "AddMinutes": return $"date_add({left}, interval ({args1}) minute)";
|
||||
case "AddMonths": return $"date_add({left}, interval ({args1}) month)";
|
||||
case "AddSeconds": return $"date_add({left}, interval ({args1}) second)";
|
||||
case "AddTicks": return $"date_add({left}, interval ({args1})/10 microsecond)";
|
||||
case "AddYears": return $"date_add({left}, interval ({args1}) year)";
|
||||
case "Add": return $"({left}+{args1})";
|
||||
case "AddDays": return $"({left}+{args1})";
|
||||
case "AddHours": return $"({left}+({args1})/24)";
|
||||
case "AddMilliseconds": return $"({left}+({args1})/86400000)";
|
||||
case "AddMinutes": return $"({left}+({args1})/1440)";
|
||||
case "AddMonths": return $"add_months({left},{args1})";
|
||||
case "AddSeconds": return $"({left}+({args1})/86400)";
|
||||
case "AddTicks": return $"({left}+({args1})/864000000000)";
|
||||
case "AddYears": return $"add_months({left},12)";
|
||||
case "Subtract":
|
||||
if (exp.Arguments[0].Type.FullName == "System.DateTime" || exp.Arguments[0].Type.GenericTypeArguments.FirstOrDefault()?.FullName == "System.DateTime")
|
||||
return $"timestampdiff(microsecond, {args1}, {left})";
|
||||
return $"({args1}-{left})";
|
||||
if (exp.Arguments[0].Type.FullName == "System.TimeSpan" || exp.Arguments[0].Type.GenericTypeArguments.FirstOrDefault()?.FullName == "System.TimeSpan")
|
||||
return $"date_sub({left}, interval ({args1}) microsecond)";
|
||||
return $"({left}-{args1})";
|
||||
break;
|
||||
case "Equals": return $"({left} = {getExp(exp.Arguments[0])})";
|
||||
case "CompareTo": return $"(({left}) - ({getExp(exp.Arguments[0])}))";
|
||||
case "ToString": return $"date_format({left}, '%Y-%m-%d %H:%i:%s.%f')";
|
||||
case "CompareTo": return $"extract(day from ({left}-({getExp(exp.Arguments[0])})))";
|
||||
case "ToString": return $"to_char({left},'YYYY-MM-DD HH24:MI:SS.FF6')";
|
||||
}
|
||||
}
|
||||
throw new Exception($"MySqlExpression 未现实函数表达式 {exp} 解析");
|
||||
throw new Exception($"OracleExpression 未现实函数表达式 {exp} 解析");
|
||||
}
|
||||
internal override string ExpressionLambdaToSqlCallTimeSpan(MethodCallExpression exp, List<SelectTableInfo> _tables, List<SelectColumnInfo> _selectColumnMap, Func<Expression[], string> getSelectGroupingMapString, SelectTableInfoType tbtype, bool isQuoteName) {
|
||||
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName);
|
||||
if (exp.Object == null) {
|
||||
switch (exp.Method.Name) {
|
||||
case "Compare": return $"({getExp(exp.Arguments[0])}-({getExp(exp.Arguments[1])}))";
|
||||
case "Compare": return $"extract(day from ({getExp(exp.Arguments[0])}-({getExp(exp.Arguments[1])})))";
|
||||
case "Equals": return $"({getExp(exp.Arguments[0])} = {getExp(exp.Arguments[1])})";
|
||||
case "FromDays": return $"(({getExp(exp.Arguments[0])})*{(long)1000000 * 60 * 60 * 24})";
|
||||
case "FromHours": return $"(({getExp(exp.Arguments[0])})*{(long)1000000 * 60 * 60})";
|
||||
case "FromMilliseconds": return $"(({getExp(exp.Arguments[0])})*1000)";
|
||||
case "FromMinutes": return $"(({getExp(exp.Arguments[0])})*{(long)1000000 * 60})";
|
||||
case "FromSeconds": return $"(({getExp(exp.Arguments[0])})*1000000)";
|
||||
case "FromTicks": return $"(({getExp(exp.Arguments[0])})/10)";
|
||||
case "Parse": return $"cast({getExp(exp.Arguments[0])} as signed)";
|
||||
case "FromDays": return $"numtodsinterval(({getExp(exp.Arguments[0])})*{(long)60 * 60 * 24},'second')";
|
||||
case "FromHours": return $"numtodsinterval(({getExp(exp.Arguments[0])})*{(long)60 * 60},'second')";
|
||||
case "FromMilliseconds": return $"numtodsinterval(({getExp(exp.Arguments[0])})/1000,'second')";
|
||||
case "FromMinutes": return $"numtodsinterval(({getExp(exp.Arguments[0])})*60,'second')";
|
||||
case "FromSeconds": return $"numtodsinterval(({getExp(exp.Arguments[0])}),'second')";
|
||||
case "FromTicks": return $"numtodsinterval(({getExp(exp.Arguments[0])})/10000000,'second')";
|
||||
case "Parse": return $"cast({getExp(exp.Arguments[0])} as interval day(9) to second(7))";
|
||||
case "ParseExact":
|
||||
case "TryParse":
|
||||
case "TryParseExact": return $"cast({getExp(exp.Arguments[0])} as signed)";
|
||||
case "TryParseExact": return $"cast({getExp(exp.Arguments[0])} as interval day(9) to second(7))";
|
||||
}
|
||||
} else {
|
||||
var left = getExp(exp.Object);
|
||||
@ -282,34 +283,34 @@ namespace FreeSql.Oracle {
|
||||
case "Add": return $"({left}+{args1})";
|
||||
case "Subtract": return $"({left}-({args1}))";
|
||||
case "Equals": return $"({left} = {getExp(exp.Arguments[0])})";
|
||||
case "CompareTo": return $"({left}-({getExp(exp.Arguments[0])}))";
|
||||
case "ToString": return $"cast({left} as char)";
|
||||
case "CompareTo": return $"extract(day from ({left}-({getExp(exp.Arguments[0])})))";
|
||||
case "ToString": return $"to_char({left})";
|
||||
}
|
||||
}
|
||||
throw new Exception($"MySqlExpression 未现实函数表达式 {exp} 解析");
|
||||
throw new Exception($"OracleExpression 未现实函数表达式 {exp} 解析");
|
||||
}
|
||||
internal override string ExpressionLambdaToSqlCallConvert(MethodCallExpression exp, List<SelectTableInfo> _tables, List<SelectColumnInfo> _selectColumnMap, Func<Expression[], string> getSelectGroupingMapString, SelectTableInfoType tbtype, bool isQuoteName) {
|
||||
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName);
|
||||
if (exp.Object == null) {
|
||||
switch (exp.Method.Name) {
|
||||
case "ToBoolean": return $"({getExp(exp.Arguments[0])} not in ('0','false'))";
|
||||
case "ToByte": return $"cast({getExp(exp.Arguments[0])} as unsigned)";
|
||||
case "ToChar": return $"substr(cast({getExp(exp.Arguments[0])} as char), 1, 1)";
|
||||
case "ToDateTime": return $"cast({getExp(exp.Arguments[0])} as datetime)";
|
||||
case "ToDecimal": return $"cast({getExp(exp.Arguments[0])} as decimal(36,18))";
|
||||
case "ToDouble": return $"cast({getExp(exp.Arguments[0])} as decimal(32,16))";
|
||||
//case "ToBoolean": return $"({getExp(exp.Arguments[0])} not in ('0','false'))";
|
||||
case "ToByte": return $"cast({getExp(exp.Arguments[0])} as number)";
|
||||
case "ToChar": return $"substr(to_char({getExp(exp.Arguments[0])}), 1, 1)";
|
||||
case "ToDateTime": return $"to_timestamp({getExp(exp.Arguments[0])},'YYYY-MM-DD HH24:MI:SS.FF6')";
|
||||
case "ToDecimal": return $"cast({getExp(exp.Arguments[0])} as number)";
|
||||
case "ToDouble": return $"cast({getExp(exp.Arguments[0])} as number)";
|
||||
case "ToInt16":
|
||||
case "ToInt32":
|
||||
case "ToInt64":
|
||||
case "ToSByte": return $"cast({getExp(exp.Arguments[0])} as signed)";
|
||||
case "ToSingle": return $"cast({getExp(exp.Arguments[0])} as decimal(14,7))";
|
||||
case "ToString": return $"cast({getExp(exp.Arguments[0])} as char)";
|
||||
case "ToSByte": return $"cast({getExp(exp.Arguments[0])} as number)";
|
||||
case "ToSingle": return $"cast({getExp(exp.Arguments[0])} as number)";
|
||||
case "ToString": return $"to_char({getExp(exp.Arguments[0])})";
|
||||
case "ToUInt16":
|
||||
case "ToUInt32":
|
||||
case "ToUInt64": return $"cast({getExp(exp.Arguments[0])} as unsigned)";
|
||||
case "ToUInt64": return $"cast({getExp(exp.Arguments[0])} as number)";
|
||||
}
|
||||
}
|
||||
throw new Exception($"MySqlExpression 未现实函数表达式 {exp} 解析");
|
||||
throw new Exception($"OracleExpression 未现实函数表达式 {exp} 解析");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,22 +16,26 @@ namespace FreeSql.Oracle {
|
||||
internal override DbParameter AppendParamter(List<DbParameter> _params, string parameterName, Type type, object value) {
|
||||
if (string.IsNullOrEmpty(parameterName)) parameterName = $"p_{_params?.Count}";
|
||||
else if (_orm.CodeFirst.IsSyncStructureToLower) parameterName = parameterName.ToLower();
|
||||
var ret = new OracleParameter { ParameterName = $":{parameterName}", Value = value };
|
||||
var tp = _orm.CodeFirst.GetDbInfo(type)?.type;
|
||||
if (tp != null) {
|
||||
ret.OracleDbType = (OracleDbType)tp.Value;
|
||||
var dbtype = (OracleDbType)_orm.CodeFirst.GetDbInfo(type)?.type;
|
||||
if (dbtype == OracleDbType.Boolean) {
|
||||
if (value == null) value = null;
|
||||
else value = (bool)value == true ? 1 : 0;
|
||||
dbtype = OracleDbType.Int16;
|
||||
}
|
||||
var ret = new OracleParameter { ParameterName = $":{parameterName}", OracleDbType = dbtype, Value = value };
|
||||
_params?.Add(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
internal override DbParameter[] GetDbParamtersByObject(string sql, object obj) =>
|
||||
Utils.GetDbParamtersByObject<OracleParameter>(sql, obj, ":", (name, type, value) => {
|
||||
var ret = new OracleParameter { ParameterName = $":{name}", Value = value };
|
||||
var tp = _orm.CodeFirst.GetDbInfo(type)?.type;
|
||||
if (tp != null) {
|
||||
ret.OracleDbType = (OracleDbType)tp.Value;
|
||||
var dbtype = (OracleDbType)_orm.CodeFirst.GetDbInfo(type)?.type;
|
||||
if (dbtype == OracleDbType.Boolean) {
|
||||
if (value == null) value = null;
|
||||
else value = (bool)value == true ? 1 : 0;
|
||||
dbtype = OracleDbType.Int16;
|
||||
}
|
||||
var ret = new OracleParameter { ParameterName = $":{name}", OracleDbType = dbtype, Value = value };
|
||||
return ret;
|
||||
});
|
||||
|
||||
@ -40,6 +44,7 @@ namespace FreeSql.Oracle {
|
||||
internal override string QuoteParamterName(string name) => $":{(_orm.CodeFirst.IsSyncStructureToLower ? name.ToLower() : name)}";
|
||||
internal override string IsNull(string sql, object value) => $"nvl({sql}, {value})";
|
||||
internal override string StringConcat(string left, string right, Type leftType, Type rightType) => $"{left} || {right}";
|
||||
internal override string Mod(string left, string right, Type leftType, Type rightType) => $"mod({left}, {right})";
|
||||
|
||||
internal override string QuoteWriteParamter(Type type, string paramterName) => paramterName;
|
||||
internal override string QuoteReadColumn(Type type, string columnName) => columnName;
|
||||
|
@ -100,6 +100,7 @@ namespace FreeSql.PostgreSQL {
|
||||
internal override string QuoteParamterName(string name) => $"@{(_orm.CodeFirst.IsSyncStructureToLower ? name.ToLower() : name)}";
|
||||
internal override string IsNull(string sql, object value) => $"coalesce({sql}, {value})";
|
||||
internal override string StringConcat(string left, string right, Type leftType, Type rightType) => $"{left} || {right}";
|
||||
internal override string Mod(string left, string right, Type leftType, Type rightType) => $"{left} % {right}";
|
||||
|
||||
internal override string QuoteWriteParamter(Type type, string paramterName) => paramterName;
|
||||
internal override string QuoteReadColumn(Type type, string columnName) => columnName;
|
||||
|
@ -38,6 +38,7 @@ namespace FreeSql.SqlServer {
|
||||
internal override string QuoteParamterName(string name) => $"@{(_orm.CodeFirst.IsSyncStructureToLower ? name.ToLower() : name)}";
|
||||
internal override string IsNull(string sql, object value) => $"isnull({sql}, {value})";
|
||||
internal override string StringConcat(string left, string right, Type leftType, Type rightType) => $"{(leftType.FullName == "System.String" ? left : $"cast({left} as nvarchar)")} + {(rightType.FullName == "System.String" ? right : $"cast({right} as nvarchar)")}";
|
||||
internal override string Mod(string left, string right, Type leftType, Type rightType) => $"{left} % {right}";
|
||||
|
||||
internal override string QuoteWriteParamter(Type type, string paramterName) => paramterName;
|
||||
internal override string QuoteReadColumn(Type type, string columnName) => columnName;
|
||||
|
Loading…
x
Reference in New Issue
Block a user