Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VB.net - Macro Substitution
Message
From
07/01/2011 11:53:37
 
 
General information
Forum:
ASP.NET
Category:
LINQ
Environment versions
Environment:
VB 9.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01488984
Message ID:
01495156
Views:
89
Hello Viv.

Sorry it took so long to respond back, but i had to move this project aside for two other projects.

After a whole day of reading and testing and trying, i decided to back with your first suggestion (HasFlag()) - which seems to be the preferred method when you use .NET 4.

However it still does not work :-(

I am getting now the error:
"Message: Sys.WebForms.PageRequestManagerServerErrorException: Method 'Boolean IncludesCode(Int32)' has no supported translation to SQL."

here is how i have set this up:
' had to spread this - the UT compiler did not like that one
< 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
' had to spread this - the UT compiler did not like that one
    < S y s t e m .Runtime.CompilerServices.Extension()> _
    Public Function IncludesCode(ByVal DocSecurityValue As Integer) As Boolean
        Dim sc As New e_SecurityCodes
        If sc.HasFlag(DirectCast(DocSecurityValue, e_SecurityCodes)) Then
            Return True
        End If
        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.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, "."),
                       ...
                       Doc_Type_Level1 = col_Row.Doc_Type_Level1,
                       Doc_Type_Level2 = col_Row.Doc_Type_Level2,
                       Doc_Type_Level3 = col_Row.Doc_Type_Level3,
                       Type_Level1 = z.Type_Level1,
                       Type_Level2 = z.Type_Level2,
                       Type_Level3 = z.Type_Level3,
                       SecurityCode = z.SecurityCode
                  Order By Patient_Last

                  ...

                 result_0.ToList()

                 Dim result_Match =
                     (From x In result_0
                     Where IncludesCode(x.SecurityCode)
                     Select x).ToList()
   End Sub
End Class
My research tells me that that error means linq can not translate the function into a sql statement and the function (obviously) will not be available to sql when the sql-statment gets executed.

Do you have any other thoughts, suggestions?

Thank you for all your help!
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform