c# - 在 Query 上用另一个模型初始化模型
问题描述
我在 Web api 中使用 Dapper。我在 SQL Server DB 中有两个表,第一个称为航班,并且有两个“位置”(起点和目的地),它们是外键并分配有机场代码(TLV、IST 等),我还有另一个表“位置”包含以下列:代码、机场和国家/地区。
我的课|| 型号为:
飞行.cs:
public class Flight
{
int ID { get; set; }
Location StartingPoint { get; set; }
Location Destination { get; set; }
DateTime StartingPoint_Departure { get; set; }
DateTime StaringPoint_Arrival { get; set; }
DateTime Destination_Departure { get; set; }
DateTime Destination_Arrival { get; set; }
float Base_Price { get; set; }
Type type { get; set; }
}
位置.cs:
public class Location
{
public string Code { get; set; }
public string Airport { get; set; }
public string Country { get; set; }
}
现在我想用外键分配的完整类来分配飞行中的位置值。我不知道它是怎么称呼的,所以我希望你能理解。
解决方案
推荐阅读
- android - 如何在android 9中允许Http
- api - 如何使用身份验证令牌从 CATSone API 中提取数据?
- react-native - 无法从领域数据库架构中获取值
- .net - 带有等待 httpClient 的异步调用不起作用
- r - 预测和错误的R编程错误是predict.svm:测试数据与模型不匹配
- android-studio - 使用具有某些网络类型的 AS Emulator 进行测试时,应用程序无法正常工作
- solr - Solr/Lucene 简单运算符“或”误解/在不同字段中搜索相同的单词
- python - 根据列值和列表创建列
- wordpress - 在 woocommerce 中注册时防止自动登录
- amazon-web-services - 对 Quicksight API 的 CORS 预检选项请求 aws-sdk 403 错误