, LINQ to Entities, BLL. , BLL, :
"System.Collections.Generic.IEnumerable 1[[OrgName.ProjName.bllTableB,
ProjNameBLL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]'
to type
'System.Collections.Generic.List 1 [[OrgName.ProjName.bllTableB, ProjNameBLL, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = null]] '. LINQ to Entities EDM- .
, .ToList() GetTableAByID(Int32) :
Public Class TableA
Public Property TableAID as Integer
Public Property TableBs as New List(Of TableB)()
Public ReadOnly Property Amount as Decimal
Get
If Me.TableBs.Count > 0 Then
Return Me.TableBs.Sum(Function(tb) tb.Amount)
Else
Return 0
End If
End Get
End Property
Public Shared Function GetTableAs() As IQueryable(Of TableA)
Dim db As New DataAccess.ProjNameEntities()
Return (
From ta In db.TableAs
Order By ta.PaidDate Descending
Select New TableA With {
.TableAID = ta.TableAID,
.TableBs = (
From tb In db.TableBs
Where tb.TableAID = ta.TableAID
Select New TableB With {
.Amount = tb.Amount
}
)
}
)
End Function
Public Shared Function GetTableAByID(TableAID as Integer) as List(Of TableA)
Return (
From ta in GetTableAs()
Where ta.TableAID = TableAID
).ToList()
End Function
End Class
Public Class TableB
Public Property TableBID as Integer
Public Property TableAID as Integer
Public Property Amount as Decimal
End Class
, DbQuery<T> List<T>, , . , , - . , .
, New TableB, List(Of TableB). , (, , TableB.Amount), .
, - .
:
facepalm, , .ToList() :
.TableBs = (
From tb In db.TableBs
Where tb.TableAID = ta.TableAID
Select New TableB With {
.Amount = tb.Amount
}
).ToList()