C# 使用Linq查询和EntityFrameworkCore 2.2返回动态字段
我有以下POCOC# 使用Linq查询和EntityFrameworkCore 2.2返回动态字段,c#,linq,entity-framework-core,C#,Linq,Entity Framework Core,我有以下POCO public class Trader : AuditableEntity { public string Name { get; set; } public string Telephone { get; set; } public string Email { get; set; } public string Website { get; set; } public List<Addre
public class Trader : AuditableEntity
{
public string Name { get; set; }
public string Telephone { get; set; }
public string Email { get; set; }
public string Website { get; set; }
public List<Address> Addresses { get; set; }
}
public class Address : AuditableEntity
{
public Trader Trader { get; set; }
/* reduce for brevity*/
public decimal Latitude { get; set; }
public decimal Longitude { get; set; }
public IPoint Location { get; set; }
}
在迁移到EntityFrameworkCore
2.2之前,将使用存储过程。在存储过程中,我可以动态返回交易者lat long与传入lat long的距离以及返回数据
Distance = (@GEO1.STDistance(geography::Point(ISNULL(Latitude,0.000000),ISNULL(Longitude,0.000000), 4326)))
我是否可以使用linq动态地定位和选择距离,方法与存储过程相同,并有效地将其添加到返回中
Distance = (@GEO1.STDistance(geography::Point(ISNULL(Latitude,0.000000),ISNULL(Longitude,0.000000), 4326)))