Click here to Skip to main content
12,511,920 members (45,924 online)
   

LINQ

 
GeneralRe: Linq "Not In" sql Query Pin
d@nish 28-Oct-09 22:30
member d@nish 28-Oct-09 22:30 
QuestionError : Calling SSIS package from .Net Pin
pinky2226-Oct-09 11:07
memberpinky2226-Oct-09 11:07 
AnswerRe: Error : Calling SSIS package from .Net Pin
Vuyiswa Maseko4-Nov-09 21:38
memberVuyiswa Maseko4-Nov-09 21:38 
GeneralRe: Error : Calling SSIS package from .Net Pin
kumarkjai9-Nov-09 6:22
memberkumarkjai9-Nov-09 6:22 
GeneralRe: Error : Calling SSIS package from .Net Pin
Vuyiswa Maseko9-Nov-09 19:35
memberVuyiswa Maseko9-Nov-09 19:35 
GeneralRe: Error : Calling SSIS package from .Net Pin
kumarkjai9-Nov-09 20:59
memberkumarkjai9-Nov-09 20:59 
GeneralRe: Error : Calling SSIS package from .Net Pin
Vuyiswa Maseko9-Nov-09 21:45
memberVuyiswa Maseko9-Nov-09 21:45 
GeneralRe: Error : Calling SSIS package from .Net Pin
kumarkjai9-Nov-09 21:55
memberkumarkjai9-Nov-09 21:55 
GeneralRe: Error : Calling SSIS package from .Net Pin
Vuyiswa Maseko9-Nov-09 22:32
memberVuyiswa Maseko9-Nov-09 22:32 
GeneralRe: Error : Calling SSIS package from .Net Pin
kumarkjai10-Nov-09 22:54
memberkumarkjai10-Nov-09 22:54 
GeneralRe: Error : Calling SSIS package from .Net Pin
Vuyiswa Maseko10-Nov-09 22:58
memberVuyiswa Maseko10-Nov-09 22:58 
QuestionLinq2Sql: Adding an object with childs Pin
Quake2Player24-Oct-09 14:00
memberQuake2Player24-Oct-09 14:00 
QuestionHow do I do an effective Except Pin
TheFoZ22-Oct-09 5:55
memberTheFoZ22-Oct-09 5:55 
AnswerRe: How do I do an effective Except Pin
Gideon Engelberth22-Oct-09 8:27
memberGideon Engelberth22-Oct-09 8:27 
Perhaps the difference comes from the different conditions you are using. In the original, you are not taking "distinct" items only and you are comparing based on both processId and process. In the LINQ version, you are taking both distinct and comparing only on processID.

There is an overload of Except that may help you out here. It takes an additional IEqualityComparer parameter. You can use that parameter to implement the custom equality operation. Also, Except has an implementation detail that trips up everyone the first time they use except. As well as being "Equals", the objects must have the same "GetHashCode" because Except will use a HashSet to store the objects from the first sequence. This also has the side effect of automatically doing a "distinct" on the two sequences. One trick you can use to get around this is to override GetHashCode on your object to just return a constant value that is the same for all instances. The tradeoff is that hashtables and hashsets will go from O(1) to O(n).

Below is a simple IEqualityComparer I whipped up to take a delegate for the comparisons so you don't have to make a separate class for each comparison. (If there is something similar in the framework, I don't know about it.)

Public Class DelegateEqualityComparer(Of T)
    Implements IEqualityComparer(Of T)
 
    Public Sub New(ByVal comparison As Func(Of T, T, Boolean))
        Me.New(comparison, Nothing)
    End Sub
    Public Sub New(ByVal comparison As Func(Of T, T, Boolean), ByVal hash As Func(Of T, Integer))
        If comparison Is Nothing Then Throw New ArgumentNullException("comparison")
        _comparison = comparison
        _hash = hash
    End Sub
 
    Private _comparison As Func(Of T, T, Boolean)
    Private _hash As Func(Of T, Integer)
 
    Public Function ComparerEquals(ByVal x As T, ByVal y As T) As Boolean Implements System.Collections.Generic.IEqualityComparer(Of T).Equals
        Return _comparison(x, y)
    End Function
 
    Public Function ComparerGetHashCode(ByVal obj As T) As Integer Implements System.Collections.Generic.IEqualityComparer(Of T).GetHashCode
        If _hash Is Nothing Then
            Return obj.GetHashCode()
        Else
            Return _hash(obj)
        End If
    End Function
 
End Class

GeneralRe: How do I do an effective Except Pin
TheFoZ22-Oct-09 21:56
memberTheFoZ22-Oct-09 21:56 
GeneralDynamic Aggregates on Report Rows Pin
Brady Kelly21-Oct-09 10:05
memberBrady Kelly21-Oct-09 10:05 
GeneralRe: Dynamic Aggregates on Report Rows Pin
J4amieC21-Oct-09 21:57
mvpJ4amieC21-Oct-09 21:57 
GeneralRe: Dynamic Aggregates on Report Rows Pin
Brady Kelly22-Oct-09 0:57
memberBrady Kelly22-Oct-09 0:57 
GeneralRe: Dynamic Aggregates on Report Rows Pin
J4amieC22-Oct-09 1:24
mvpJ4amieC22-Oct-09 1:24 
GeneralRe: Dynamic Aggregates on Report Rows Pin
Brady Kelly22-Oct-09 5:14
memberBrady Kelly22-Oct-09 5:14 
GeneralRe: Dynamic Aggregates on Report Rows Pin
J4amieC22-Oct-09 5:34
mvpJ4amieC22-Oct-09 5:34 
GeneralRe: Dynamic Aggregates on Report Rows Pin
Brady Kelly22-Oct-09 8:23
memberBrady Kelly22-Oct-09 8:23 
GeneralRe: Dynamic Aggregates on Report Rows Pin
J4amieC22-Oct-09 22:03
mvpJ4amieC22-Oct-09 22:03 
GeneralRe: Dynamic Aggregates on Report Rows Pin
Brady Kelly23-Oct-09 20:54
memberBrady Kelly23-Oct-09 20:54 
GeneralRe: Dynamic Aggregates on Report Rows Pin
Gideon Engelberth22-Oct-09 6:01
memberGideon Engelberth22-Oct-09 6:01 
GeneralRe: Dynamic Aggregates on Report Rows Pin
Brady Kelly22-Oct-09 8:24
memberBrady Kelly22-Oct-09 8:24 
QuestionInsert New Row in XML? Pin
Aman Bhullar20-Oct-09 19:10
memberAman Bhullar20-Oct-09 19:10 
AnswerRe: Insert New Row in XML? Pin
Mirko198021-Oct-09 5:32
memberMirko198021-Oct-09 5:32 
QuestionHow to use DbLinq that suport Linq To Oracle? Pin
mehdi talebi20-Oct-09 8:44
membermehdi talebi20-Oct-09 8:44 
AnswerRe: How to use DbLinq that suport Linq To Oracle? Pin
spiritboy15-Dec-09 18:27
memberspiritboy15-Dec-09 18:27 
QuestionLINQ-GRIDVIEW Pin
sris 42620-Oct-09 4:09
membersris 42620-Oct-09 4:09 
GeneralCannot get LINQ statement to work Pin
jmonfu20-Oct-09 2:29
memberjmonfu20-Oct-09 2:29 
GeneralRe: Cannot get LINQ statement to work Pin
J4amieC20-Oct-09 2:41
mvpJ4amieC20-Oct-09 2:41 
GeneralRe: Cannot get LINQ statement to work Pin
MREcoolio27-Oct-09 13:11
memberMREcoolio27-Oct-09 13:11 
GeneralRe: Cannot get LINQ statement to work Pin
MREcoolio27-Oct-09 13:02
memberMREcoolio27-Oct-09 13:02 
QuestionLinq to Oracle?? Pin
Saiyed Alam19-Oct-09 0:48
memberSaiyed Alam19-Oct-09 0:48 
AnswerRe: Linq to Oracle?? Pin
Pete O'Hanlon19-Oct-09 2:07
mvpPete O'Hanlon19-Oct-09 2:07 
AnswerRe: Linq to Oracle?? Pin
Devart22-Oct-09 2:04
memberDevart22-Oct-09 2:04 
QuestionLINQ Syntax, Join 2 Tables - Output new table using .CopyToDataTable Pin
wiley_junk@hotmail.com15-Oct-09 13:58
memberwiley_junk@hotmail.com15-Oct-09 13:58 
Questionlinqtoxml-update Pin
arkiboys13-Oct-09 12:35
memberarkiboys13-Oct-09 12:35 
AnswerRe: linqtoxml-update Pin
Richard MacCutchan13-Oct-09 13:21
memberRichard MacCutchan13-Oct-09 13:21 
GeneralRe: linqtoxml-update Pin
arkiboys13-Oct-09 13:23
memberarkiboys13-Oct-09 13:23 
GeneralRe: linqtoxml-update Pin
Richard MacCutchan13-Oct-09 22:02
memberRichard MacCutchan13-Oct-09 22:02 
AnswerRe: linqtoxml-update Pin
Mirko198013-Oct-09 22:44
memberMirko198013-Oct-09 22:44 
GeneralRe: linqtoxml-update Pin
arkiboys14-Oct-09 0:14
memberarkiboys14-Oct-09 0:14 
GeneralRe: linqtoxml-update Pin
Mirko198014-Oct-09 1:02
memberMirko198014-Oct-09 1:02 
GeneralRe: linqtoxml-update Pin
arkiboys14-Oct-09 1:37
memberarkiboys14-Oct-09 1:37 
GeneralRe: linqtoxml-update Pin
Mirko198014-Oct-09 2:09
memberMirko198014-Oct-09 2:09 
GeneralRe: linqtoxml-update Pin
arkiboys14-Oct-09 3:50
memberarkiboys14-Oct-09 3:50 
GeneralRe: linqtoxml-update Pin
Mirko198014-Oct-09 5:05
memberMirko198014-Oct-09 5:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web02 | 2.8.160929.1 | Last Updated 10 Aug 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid