I have the following subsonic entities
TInvoiceHeader
TAccountAssociation
How can I achieve the following in LINQ (subsonic)
SELECT * from TInvoiceHeader
WHERE custid IN
(SELECT custid FROM TAccountAssociation
WHERE username = 'a')
I need to bind the results to a GridView.
Update: I tried
Dim accounts As List(Of TAccountAssociation) = _
TAccountAssociation.Find(Function(x) x.UserName = "a")
GridView1.DataSource = TInvoiceHeader.All() _
.Where(Function(x) accounts.Contains(x.custID))
GridView1.DataBind()
But I get an error "...nested function dows not have the same signature as delegate"
Update:
I really dont freaking get this...
why does this work
Dim accounts() As String = {"N12345", "A12455"}
GridView1.DataSource = TInvoiceHeader.All(). _
Where(Function(c) accounts.Contains(c.custID))
GridView1.DataBind()
But this doesn't
Dim accounts = TAccountAssociation.Find(Function(x) x.UserName = "a")
GridView1.DataSource = TInvoiceHeader.All(). _
Where(Function(c) accounts.Contains(c.custID))
GridView1.DataBind()
Update
I ended up using the Fluent Query
GridView1.DataSource = New customerWEBDB().Select.From(Of TInvoiceHeader)_
.Where("custID") _
.In(New customerWEBDB().SelectColumns("custID") _
.From(Of TAccountAssociation) _
.Where("UserName").IsEqualTo("aaa")) _
.ExecuteTypedList(Of TInvoiceHeader)()
GridView1.DataBind()
Hopefully someone will show me something better.