Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 2 additions & 15 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
<Project>
<ItemGroup Condition="'$(TargetFramework)' != 'net45'">
<!-- Any update of these version must be accompanied by the appropriate
change in EF6.PG/content -->
<PackageReference Update="Npgsql" Version="4.1.3" />
<PackageReference Update="Npgsql.LegacyPostgis" Version="4.1.3" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
<!-- Any update of these version must be accompanied by the appropriate
change in EF6.PG/content -->
<PackageReference Update="Npgsql" Version="4.0.10" />
<PackageReference Update="Npgsql.LegacyPostgis" Version="4.0.10" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="EntityFramework" Version="6.4.0" />
<PackageReference Update="Npgsql" Version="7.0.9" />
<PackageReference Update="EntityFramework" Version="6.5.1" />

<PackageReference Update="NUnit" Version="3.12.0" />
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="16.4.0" />
Expand Down
3 changes: 1 addition & 2 deletions EF6.PG.Tests/EF6.PG.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<LangVersion>latest</LangVersion>
<TargetFrameworks>net45;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net6.0</TargetFrameworks>
<RootNamespace>EntityFramework6.Npgsql.Tests</RootNamespace>
<AssemblyName>EntityFramework6.Npgsql.Tests</AssemblyName>
</PropertyGroup>
Expand All @@ -11,7 +11,6 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="NUnit3TestAdapter" />
<PackageReference Include="NLog" />
<PackageReference Include="Npgsql.LegacyPostgis" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\EF6.PG\EF6.PG.csproj" />
Expand Down
79 changes: 77 additions & 2 deletions EF6.PG.Tests/EntityFrameworkBasicTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ public void InsertAndSelect()
}
var someParameter = "Some";
Assert.IsTrue(context.Posts.Any(p => p.Title.StartsWith(someParameter)));
Assert.IsTrue(context.Posts.All(p => p.Title != null));
Assert.IsTrue(context.Posts.Any(p => someParameter != null));
Assert.IsTrue(context.Posts.Select(p => p.VarbitColumn == varbitVal).First());
Assert.IsTrue(context.Posts.All(p => p.VarbitColumn != null));
Assert.IsTrue(context.Posts.Any(p => varbitVal != null));
Assert.IsTrue(context.Posts.Select(p => p.VarbitColumn == "10011").First());
Assert.AreEqual(1, context.NoColumnsEntities.Count());
}
Expand Down Expand Up @@ -147,6 +151,77 @@ public void SelectWithWhere_Ef_TruncateTime()
}
}

[Test]
public void Select_Ef_Timezone()
{
var createdOnDate = new DateTimeOffset(2020, 12, 03, 22, 23, 0, TimeSpan.Zero);
using (var context = new BloggingContext(ConnectionString))
{
context.Logs.Add(new Log()
{
CreationDate = createdOnDate
});
context.SaveChanges();
}

using (var context = new BloggingContext(ConnectionString))
{
context.Database.ExecuteSqlCommand("SET TIMEZONE='UTC';");
var query = context.Logs.Select(p => NpgsqlDateTimeFunctions.Timezone("Pacific/Honolulu", p.CreationDate));
var createdOnDateInTimeZone = query.FirstOrDefault();
Assert.AreEqual(new DateTime(2020, 12, 03, 12, 23, 0), createdOnDateInTimeZone);
}
}

[Test]
public void Select_Ef_StringAgg()
{
DateTime createdOnDate = new DateTime(2014, 05, 08);
using (var context = new BloggingContext(ConnectionString))
{
var blog = new Blog()
{
Name = "Blog 1"
};
blog.Posts = new List<Post>();

blog.Posts.Add(new Post()
{
Content = "Content 1",
Rating = 1,
Title = "Title 1",
CreationDate = createdOnDate
});
blog.Posts.Add(new Post()
{
Content = "Content 2",
Rating = 2,
Title = "Title 2",
CreationDate = createdOnDate
});
blog.Posts.Add(new Post()
{
Content = "Content 3",
Rating = 3,
Title = "Title 3",
CreationDate = createdOnDate
});

context.Blogs.Add(blog);
context.SaveChanges();
}

using (var context = new BloggingContext(ConnectionString))
{
context.Database.Initialize(true);
var query = context.Posts
.GroupBy(p => p.BlogId)
.Select(g => g.Select(x => x.Title).StringAgg());
var result = query.FirstOrDefault();
Assert.AreEqual("Title 1, Title 2, Title 3", result);
}
}

[Test]
public void SelectWithLike_SpecialCharacters()
{
Expand Down Expand Up @@ -791,7 +866,7 @@ public void Test_string_null_propagation()
Console.WriteLine(query.ToString());
StringAssert.AreEqualIgnoringCase(
"SELECT CASE WHEN (COALESCE(@p__linq__0,E'default_value') IS NULL) THEN (E'')"
+ " WHEN (@p__linq__0 IS NULL) THEN (E'default_value') ELSE (@p__linq__0) END ||"
+ " WHEN (CAST (@p__linq__0 AS varchar) IS NULL) THEN (E'default_value') ELSE (@p__linq__0) END ||"
+ " E'_postfix' AS \"C1\" FROM \"dbo\".\"Blogs\" AS \"Extent1\"",
query.ToString());
}
Expand Down Expand Up @@ -819,7 +894,7 @@ public void Test_string_multiple_null_propagation()
Console.WriteLine(query.ToString());
StringAssert.AreEqualIgnoringCase(
"SELECT CASE WHEN (COALESCE(@p__linq__0,COALESCE(@p__linq__1,@p__linq__2)) IS NULL)"
+ " THEN (E'') WHEN (@p__linq__0 IS NULL) THEN (COALESCE(@p__linq__1,@p__linq__2)) ELSE"
+ " THEN (E'') WHEN (CAST (@p__linq__0 AS varchar) IS NULL) THEN (COALESCE(@p__linq__1,@p__linq__2)) ELSE"
+ " (@p__linq__0) END || E'_postfix' AS \"C1\" FROM \"dbo\".\"Blogs\" AS \"Extent1\"",
query.ToString());
}
Expand Down
61 changes: 0 additions & 61 deletions EF6.PG.Tests/NLogLoggingProvider.cs

This file was deleted.

Loading