forked from dotnetcore/FreeSql
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
28810
authored and
28810
committed
Dec 29, 2018
1 parent
43080a4
commit 96a944c
Showing
13 changed files
with
588 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
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 { | ||
public class OtherTest { | ||
|
||
ISelect<TableAllType> select => g.mysql.Select<TableAllType>(); | ||
|
||
public OtherTest() { | ||
NpgsqlConnection.GlobalTypeMapper.UseLegacyPostgis(); | ||
} | ||
|
||
|
||
[Fact] | ||
public void Array() { | ||
//in not in | ||
var sql111 = select.Where(a => new[] { 1, 2, 3 }.Contains(a.testFieldInt)).ToList(); | ||
var sql112 = select.Where(a => new[] { 1, 2, 3 }.Contains(a.testFieldInt) == false).ToList(); | ||
var sql113 = select.Where(a => !new[] { 1, 2, 3 }.Contains(a.testFieldInt)).ToList(); | ||
|
||
var inarray = new[] { 1, 2, 3 }; | ||
var sql1111 = select.Where(a => inarray.Contains(a.testFieldInt)).ToList(); | ||
var sql1122 = select.Where(a => inarray.Contains(a.testFieldInt) == false).ToList(); | ||
var sql1133 = select.Where(a => !inarray.Contains(a.testFieldInt)).ToList(); | ||
} | ||
|
||
[Table(Name = "tb_alltype")] | ||
class TableAllType { | ||
[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 bool? testFieldBoolNullable { get; set; } | ||
public sbyte? testFieldSByteNullable { get; set; } | ||
public short? testFieldShortNullable { get; set; } | ||
public int? testFieldIntNullable { 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 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 enum TableAllTypeEnumType1 { e1, e2, e3, e5 } | ||
[Flags] public enum TableAllTypeEnumType2 { f1, f2, f3 } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
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 { | ||
public class OtherTest { | ||
|
||
ISelect<TableAllType> select => g.sqlserver.Select<TableAllType>(); | ||
|
||
public OtherTest() { | ||
NpgsqlConnection.GlobalTypeMapper.UseLegacyPostgis(); | ||
} | ||
|
||
|
||
[Fact] | ||
public void Array() { | ||
//in not in | ||
var sql111 = select.Where(a => new[] { 1, 2, 3 }.Contains(a.testFieldInt)).ToList(); | ||
//var sql112 = select.Where(a => new[] { 1, 2, 3 }.Contains(a.testFieldInt) == false).ToList(); | ||
var sql113 = select.Where(a => !new[] { 1, 2, 3 }.Contains(a.testFieldInt)).ToList(); | ||
|
||
var inarray = new[] { 1, 2, 3 }; | ||
var sql1111 = select.Where(a => inarray.Contains(a.testFieldInt)).ToList(); | ||
//var sql1122 = select.Where(a => inarray.Contains(a.testFieldInt) == false).ToList(); | ||
var sql1133 = select.Where(a => !inarray.Contains(a.testFieldInt)).ToList(); | ||
} | ||
|
||
[Table(Name = "tb_alltype")] | ||
class TableAllType { | ||
[Column(IsIdentity = true, IsPrimary = true)] | ||
public int Id { get; set; } | ||
|
||
[Column(Name = "testFieldBool1111")] | ||
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 DateTimeOffset testFieldDateTimeOffset { get; set; } | ||
public byte[] testFieldBytes { get; set; } | ||
public string testFieldString { get; set; } | ||
public Guid testFieldGuid { get; set; } | ||
|
||
public bool? testFieldBoolNullable { get; set; } | ||
public sbyte? testFieldSByteNullable { get; set; } | ||
public short? testFieldShortNullable { get; set; } | ||
public int? testFieldIntNullable { 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 DateTimeOffset? testFieldDateTimeNullableOffset { get; set; } | ||
public Guid? testFieldGuidNullable { get; set; } | ||
|
||
public TableAllTypeEnumType1 testFieldEnum1 { get; set; } | ||
public TableAllTypeEnumType1? testFieldEnum1Nullable { get; set; } | ||
public TableAllTypeEnumType2 testFieldEnum2 { get; set; } | ||
public TableAllTypeEnumType2? testFieldEnum2Nullable { get; set; } | ||
} | ||
|
||
public enum TableAllTypeEnumType1 { e1, e2, e3, e5 } | ||
[Flags] public enum TableAllTypeEnumType2 { f1, f2, f3 } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.