Skip to content

Commit

Permalink
test for issue #4390
Browse files Browse the repository at this point in the history
  • Loading branch information
jogibear9988 committed Jan 25, 2024
1 parent 194b4e8 commit 0fe4d58
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions Tests/Linq/UserTests/Issue4390Tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using System.Linq;
using FluentAssertions;
using LinqToDB;
using LinqToDB.Mapping;
using NUnit.Framework;
using System.Linq.Dynamic.Core;
using System.Linq.Dynamic.Core.CustomTypeProviders;
using System.Collections.Generic;
using System;

namespace Tests.UserTests
{
[TestFixture]
public class Issue4390Tests : TestBase
{
[Table]
public class InfeedAdviceDTO
{
[Column] public int Id { get; set; }
}

[Table]
public class InventoryResourceDTO
{
[Column] public int InfeedAdviceID { get; set; }
}
public class MlogCombined1
{
public InfeedAdviceDTO? InfeedAdvice { get; set; }

public int? Count { get; set; }
}

public class MlogCombined2
{
public MlogCombined1? MlogCombined1 { get; set; }
}

[Test]
public void Issue4390Test([IncludeDataSources(TestProvName.AllSQLite)] string context)
{
using (var db = GetDataContext(context))
using (db.CreateLocalTable<InfeedAdviceDTO>())
using (db.CreateLocalTable<InventoryResourceDTO>())
{
db.Insert(new InventoryResourceDTO() { InfeedAdviceID = 1 });
db.Insert(new InfeedAdviceDTO() { Id = 1 });

var irs = from ir in db.GetTable<InventoryResourceDTO>() select ir;

var qry = from infeed in db.GetTable<InfeedAdviceDTO>()
join inventory in db.GetTable<InventoryResourceDTO>() on infeed.Id equals inventory.InfeedAdviceID
select new MlogCombined2
{
MlogCombined1 = new MlogCombined1
{
InfeedAdvice = infeed,
Count = irs.Count(x => x.InfeedAdviceID == infeed.Id),
}
};

var l = qry.Where(x => x.MlogCombined1 != null).Count();
}
}
}
}

0 comments on commit 0fe4d58

Please sign in to comment.