Reputation: 33
Here are the entities that i have...
Public Class Account
Public Property AccountId As integer
Public Property AccountDescription As String
Public Property Transactions As List(Of Transaction)
End Class
Public Class Transaction
Public Property TransactionId As Integer
Public Property AccountId As Integer
Public Property TransactionDescription As String
End Class
i would like to make it suc that when i do "db.Account.find(1)" for example it also loads in the list of all transactions which have the coresponding AccountId. I'm not too sure what type of relationship this is?? anyway, right now i can do
Dim acct As Account = db.Account.Find(1)
acct.Transactions = from ts in db.transactions select ts where ts.AccountId = acct.accountid
but i know this is not the correct way, there must be a way to map this out so that entity can just load everything in one shot right? Thanks for any help.
Upvotes: 0
Views: 146
Reputation: 15583
You can use db.Account.Include("Transactions").SingleOrDefault(1)
or put Transactions as virtual (I think it is Overridable in vb).
Upvotes: 1