-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Closed as not planned
Closed as not planned
Copy link
Labels
Description
Hi, I'm trying to fetch data from joining two tables but the number of rows that I'm expecting/actual result are less than it should be (actual result should be 12 but I've got only 5 rows) and there is no error. Here is my models:
MetInfo:
public class MetInfo
{
[Key]
public int StnID { get; set; }
public int MMSI { get; set; }
public DateTime RecvTime { get; set; }
public Int16? DAC { get; set; }
public Int16? FI { get; set; }
public double Longitude { get; set; }
public double Latitude { get; set; }
}
ShipList:
public class ShipList
{
[Key]
public int ShipListID { get; set; }
public int? MMSI { get; set; }
public string Name { get; set; }
public int? IMO { get; set; }
public string CallSign { get; set; }
public double? Latitude { get; set; }
public double? Longitude { get; set; }
public DateTime RecvTime { get; set; }
}
Here is my query:
(from met in vtsDbContext.MetInfos
orderby met.RecvTime descending
group met by met.MMSI into mg
join sl in vtsDbContext.ShipLists on mg.FirstOrDefault().MMSI equals sl.MMSI into ps from sl in ps.DefaultIfEmpty()
select new { mg.FirstOrDefault().MMSI, mg.FirstOrDefault().RecvTime, sl.Name }).ToList();
I've tried to compare it with EF6 by creating 2 different Console Apps. One is using EF Core and the other is using EF6. EF6 returns the expected results but EF Core does not.
Further technical details
EF Core version: 2.2.0
Database Provider: Microsoft.EntityFrameworkCore.SQLServer
Reactions are currently unavailable