Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VB.net - Macro Substitution
Message
De
14/11/2010 04:17:42
 
 
À
13/11/2010 20:35:30
Information générale
Forum:
ASP.NET
Catégorie:
LINQ
Versions des environnements
Environment:
VB 9.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01488984
Message ID:
01489064
Vues:
90
>that is a nice alternative to my Bitwise AND. But at the end of the day i still have to call a function from the LINQ, and that did not work when i tried it with my version.
>    Public Function OptionCheck_WithArray(ByRef n_Value1() As Integer, ByVal n_Value2 As Integer) As Boolean
>        ' TODO: need to loop through array
>        Return If((n_Value2 And n_Value1(0)) = n_Value1(0), True, False)
>    End Function
>This function will check if a 4 is in 102 (as an example).
>I had called that function as follows:
>        result_0 = result_0.Where(Function(f) OptionCheck_WithArray(SecurityCodes, f.SecurityCode) = True)
>but that thoughts an error, don't remember the exact text, but the research of the error reviled that LINQ can not translate that into SQL.
>I think that LINQ can not see that function when execution time is up. As I described in my original post, this works if i put the if line directly into the LINQ where command it works, but of course that only works if i have one security code, not a collection thereof.
>
>Any additional thoughts are greatly appreciated.

Don't see why it won't work with Linq. Mocking your results:
Public Class DummyRow
    Public Sub New(ByVal codes__1 As List(Of Integer))
        Codes = codes__1
    End Sub
    Public Property Codes() As List(Of Integer)
        Get
            Return m_Codes
        End Get
        Set(ByVal value As List(Of Integer))
            m_Codes = Value
        End Set
    End Property
    Private m_Codes As List(Of Integer)
End Class
then:
        Dim results As New List(Of DummyRow)()
        results.Add(New DummyRow(New List(Of Integer)() From {1, 4}))
        results.Add(New DummyRow(New List(Of Integer)() From {4, 8}))
        results.Add(New DummyRow(New List(Of Integer)() From {4, 16}))

        Dim ToCheck As SecurityCodes = SecurityCodes.Guest Or SecurityCodes.Affiliate

        Dim MatchingRows As IEnumerable(Of DummyRow) = From x In results Where ToCheck.IncludesCode(x.Codes) Select x
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform