>Message=Method 'Boolean IncludesAnyOf(e_SecurityCodes, e_SecurityCodes)' has no supported translation to SQL.
>Here is how my code looks like so far (i had to change the DirectCast o a CType call:>F l a g s() _ >Public Enum e_SecurityCodes > DMS_Accounting_All = 2 > DMS_Accounting_AR = 4 > DMS_Accounting_AP = 8 > DMS_Accounting_PR = 16 > DMS_All = 32 > DMS_Client = 64 > DMS_HR_Employee = 128 > DMS_HR_Caregiver = 256 > DMS_HR_All = 512 >End Enum > >Module SecurityTest > S y s t e m.Runtime.CompilerServices.Extension() _ > Public Function IncludesAnyOf(ByVal sc As e_SecurityCodes, ByVal DocSecurityValue As e_SecurityCodes) As Boolean > 'Dim sc_new = DirectCast(sc, e_SecurityCodes) > Dim code As e_SecurityCodes > For Each code In [Enum].GetValues(GetType(e_SecurityCodes)) > If sc.HasFlag(code) And DocSecurityValue.HasFlag(code) Then > Return True > End If > Next > Return False > End Function >End Module > >Partial Public Class _Default > ... > Protected Sub Search_Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Search_Btn.Click, Search_Btn2.Click > > Dim db = New DataClassesDataContext() > Dim result_0 = > From col_Row In db.Masters, z In db.DocumentTypes > Select > ListCol = > System.Convert.ToDateTime(col_Row.Doc_Dte).Month.ToString.PadLeft(2, "0") & "/" & > System.Convert.ToDateTime(col_Row.Doc_Dte).Day.ToString.PadLeft(2, "0") & "/" & > System.Convert.ToDateTime(col_Row.Doc_Dte).Year.ToString.Substring(2, 2) & " | " & > col_Row.Doc_Type_Level3.Trim.Substring(0, 28).PadRight(28, ".") & " | " & > col_Row.Patient_Code.Trim.Substring(0, 6).PadRight(6, ".") & " | " & > col_Row.Patient_First.Trim.Substring(0, 14).PadRight(14, ".") & " | " & > col_Row.Patient_Last.Trim.Substring(0, 15).PadRight(15, ".") & " | " & > col_Row.Resource_ID.ToString.Trim.Substring(0, 6).PadRight(6, ".") & " | " & > col_Row.Resource_First.Trim.Substring(0, 14).PadRight(14, ".") & " | " & > col_Row.Resource_Last.Trim.Substring(0, 15).PadRight(15, ".") & " | " & > col_Row.Vendor_Name.Trim.Substring(0, 19).PadRight(19, "."), > Patient_Code = col_Row.Patient_Code, > Patient_First = col_Row.Patient_First, > Patient_Last = col_Row.Patient_Last, > Resource_ID = col_Row.Resource_ID, > Resource_First = col_Row.Resource_First, > Resource_Last = col_Row.Resource_Last, > VendorID = col_Row.VendorID, > Vendor_Name = col_Row.Vendor_Name, > DocLocation = col_Row.DocLocation, > Doc_Type_Level1 = col_Row.Doc_Type_Level1, > Doc_Type_Level2 = col_Row.Doc_Type_Level2, > Doc_Type_Level3 = col_Row.Doc_Type_Level3, > Scan_Dte = col_Row.Scan_Dte, > Doc_Dte = col_Row.Doc_Dte, > Process_Dte = col_Row.Process_Dte, > Process_By = col_Row.Process_By, > Doc_Loc_Type = col_Row.Doc_Loc_Type, > Doc_Loc_Geo = col_Row.Doc_Loc_Geo, > Doc_Loc_Other = col_Row.Doc_Loc_Other, > Doc_Comment = col_Row.Doc_Comment, > Doc_ID = col_Row.Doc_ID, > Type_Level1 = z.Type_Level1, > Type_Level2 = z.Type_Level2, > Type_Level3 = z.Type_Level3, > SecurityCode = CType(z.SecurityCode, e_SecurityCodes) > Order By Patient_Last > > ... > ' link the document table to the security table > result_0 = result_0.Where(Function(f) f.Doc_Type_Level1.ToLower = f.Type_Level1.ToLower) > result_0 = result_0.Where(Function(f) f.Doc_Type_Level2.ToLower = f.Type_Level2.ToLower) > result_0 = result_0.Where(Function(f) f.Doc_Type_Level3.ToLower = f.Type_Level3.ToLower) > > result_0.ToList() > > Dim param As e_SecurityCodes = e_SecurityCodes.DMS_Accounting_AP Or e_SecurityCodes.DMS_Client > Dim result_Match = (From x In result_0 Where x.SecurityCode.IncludesAnyOf(param) Select x).ToList() >...>I am getting error mentioned above in the last line.
' The next line will execute the database query but you are not assigning the result... result_0.ToList() Dim param As e_SecurityCodes = e_SecurityCodes.DMS_Accounting_AP Or e_SecurityCodes.DMS_Client ' At this point result_0 is still an in-memory query so the next line will again use Linq-to-Sql to query the database - ' which is the cause of the error Dim result_Match = (From x In result_0 Where x.SecurityCode.IncludesAnyOf(param) Select x).ToList()You need to get the query result into a List before using Linq to filter on SecurityCode so, for example:
Dim theList = result_0.ToList() Dim param As e_SecurityCodes = e_SecurityCodes.DMS_Accounting_AP Or e_SecurityCodes.DMS_Client Dim result_Match = (From x In theList Where x.SecurityCode.IncludesAnyOf(param) Select x).ToList()