Compiled LINQ Unions

I have a slightly weak projection, so I decided to play in the production of a cinema with micro-optimization. Im working on launching on some pretty low performance tablets, so I was looking for ways to speed things up. Given that Im using LINQ to Entities, I looked at pre-compiled queries to boast high performance, and therefore came up with this simple one to return a contact list for this company.

 Public ReadOnly pContacts_list_query As Func(Of SpiraxDDWEntities, Integer, IQueryable(Of tblContacts)) = _
        CompiledQuery.Compile(Of SpiraxDDWEntities, Integer, IQueryable(Of tblContacts))(Function(ctx As SpiraxDDWEntities, pCompany_ABN As Integer) _
                                                                                           From Contact_data In ctx.tblContacts Where Contact_data.AccountNumber = pCompany_ABN
                                                                                           )

Now that’s fine, since its only one table, so the IQueryable type may be the name of the table. My question is, what if I wanted to precompile the request using connections? For example, this

    Dim Quote_QRY = From Quote_data In linEntities.tblQuote
                    Join Quote_value_data In linEntities.tblQuoteValue On Quote_data.ID Equals Quote_value_data.QuoteID
                    Join Quote_status_data In linEntities.tblQuoteStatus On Quote_data.Status Equals Quote_status_data.Abbreviation
                    Where Quote_data.AccountNo = Me.txtCompany_ABN.Text
                    Select Quote_data.ID, Status = Quote_status_data.Description, Quote_data.Contact, Quote_data.Project, Quote_value_data.QuoteValue

How can i do this?

thank

0
source
1

. . select:

Public Class Quote
   Public Property ID As String
   Public Property Status As String
   Public Property Contact As String
   Public Property Project As String
   Public Property QuoteValue As String
End Class

 Public ReadOnly Quote_query As Func(Of SpiraxDDWEntities, Integer, IQueryable(Of Quotes)) = _ 
        CompiledQuery.Compile(Of SpiraxDDWEntities, Integer, IQueryable(Of Quotes))(Function(ctx As SpiraxDDWEntities, pCompany_ABN As Integer) 
                    From Quote_data In linEntities.tblQuote 
                    Join Quote_value_data In linEntities.tblQuoteValue On Quote_data.ID Equals Quote_value_data.QuoteID 
                    Join Quote_status_data In linEntities.tblQuoteStatus On Quote_data.Status Equals Quote_status_data.Abbreviation 
                    Where Quote_data.AccountNo = Me.txtCompany_ABN.Text 
                    Select New Quote With {
                       .ID = Quote_data.ID, 
                       .Status = Quote_status_data.Description, 
                       .Contact = Quote_data.Contact, 
                       .Project = Quote_data.Project, 
                       .QuoteValue = Quote_value_data.QuoteValue 
                   }

: , Compiled Query , . , EDMX, EF , . , CSDL.

+1

All Articles