我正在阅读此http://jcmartialarts.co.uk/CSharp/Using-Lambda-Expressions-To-LEFT-JOIN-Tables/43但我无法弄清楚如何做我想做的事。我有这个表达:
Dim myData = db.Tbl_Exercises.Where(Function(x) x.Exercise_Employee_ID)
我的Tbl_Exercise
模型有一个Exercise_Type_ID
. 我想使用该 ID 从我的Tbl_Exercise_Type
模型中获取锻炼描述的类型,该模型具有ExType_Desc
我想在我的应用程序中使用的属性(代替Tbl_Exercise.Exercise_Type_ID
)。
我怎样才能做到这一点?
编辑:
这是我的模型:
Public Class Tbl_Exercise
<Key()> Public Property Exercise_ID() As Integer
Public Property Exercise_Employee_ID() As Integer
Public Property Exercise_Create_Date() As Date
<ForeignKey("Tbl_Exercise_Type")>
Public Property Exercise_Type_ID() As Integer
Public Property Exercise_Duration() As Integer
Public Overridable Property Tbl_Exercise_Type As Tbl_Exercise_Type
End Class
Public Class Tbl_Exercise_Type
<Key()> Public Property ExType_ID() As Integer
Public Property ExType_Desc() As String
Public Property Exercise_Create_Date() As Date
Public Overridable Property Tbl_Exercise() As ICollection(Of Tbl_Exercise)
End Class
Public Class ExerciseDbContext
Inherits DbContext
Public Property Tbl_Exercises As DbSet(Of Tbl_Exercise)
Public Property Tbl_Exercise_Types As DbSet(Of Tbl_Exercise_Type)
End Class
谢谢。