Click here to Skip to main content
11,417,390 members (51,242 online)
   

LINQ

 
GeneralRe: Error : Calling SSIS package from .Net Pin
Vuyiswa Maseko9-Nov-09 22:45
memberVuyiswa Maseko9-Nov-09 22:45 
GeneralRe: Error : Calling SSIS package from .Net Pin
kumarkjai9-Nov-09 22:55
memberkumarkjai9-Nov-09 22:55 
GeneralRe: Error : Calling SSIS package from .Net Pin
Vuyiswa Maseko9-Nov-09 23:32
memberVuyiswa Maseko9-Nov-09 23:32 
GeneralRe: Error : Calling SSIS package from .Net Pin
kumarkjai10-Nov-09 23:54
memberkumarkjai10-Nov-09 23:54 
GeneralRe: Error : Calling SSIS package from .Net Pin
Vuyiswa Maseko10-Nov-09 23:58
memberVuyiswa Maseko10-Nov-09 23:58 
QuestionLinq2Sql: Adding an object with childs Pin
Quake2Player24-Oct-09 15:00
memberQuake2Player24-Oct-09 15:00 
QuestionHow do I do an effective Except Pin
TheFoZ22-Oct-09 6:55
memberTheFoZ22-Oct-09 6:55 
AnswerRe: How do I do an effective Except Pin
Gideon Engelberth22-Oct-09 9:27
memberGideon Engelberth22-Oct-09 9: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 22:56
memberTheFoZ22-Oct-09 22:56 
GeneralDynamic Aggregates on Report Rows Pin
Brady Kelly21-Oct-09 11:05
memberBrady Kelly21-Oct-09 11:05 
GeneralRe: Dynamic Aggregates on Report Rows Pin
J4amieC21-Oct-09 22:57
mvpJ4amieC21-Oct-09 22:57 
GeneralRe: Dynamic Aggregates on Report Rows Pin
Brady Kelly22-Oct-09 1:57
memberBrady Kelly22-Oct-09 1:57 
GeneralRe: Dynamic Aggregates on Report Rows Pin
J4amieC22-Oct-09 2:24
mvpJ4amieC22-Oct-09 2:24 
GeneralRe: Dynamic Aggregates on Report Rows Pin
Brady Kelly22-Oct-09 6:14
memberBrady Kelly22-Oct-09 6:14 
GeneralRe: Dynamic Aggregates on Report Rows Pin
J4amieC22-Oct-09 6:34
mvpJ4amieC22-Oct-09 6:34 
GeneralRe: Dynamic Aggregates on Report Rows Pin
Brady Kelly22-Oct-09 9:23
memberBrady Kelly22-Oct-09 9:23 
GeneralRe: Dynamic Aggregates on Report Rows Pin
J4amieC22-Oct-09 23:03
mvpJ4amieC22-Oct-09 23:03 
GeneralRe: Dynamic Aggregates on Report Rows Pin
Brady Kelly23-Oct-09 21:54
memberBrady Kelly23-Oct-09 21:54 
GeneralRe: Dynamic Aggregates on Report Rows Pin
Gideon Engelberth22-Oct-09 7:01
memberGideon Engelberth22-Oct-09 7:01 
GeneralRe: Dynamic Aggregates on Report Rows Pin
Brady Kelly22-Oct-09 9:24
memberBrady Kelly22-Oct-09 9:24 
QuestionInsert New Row in XML? Pin
Aman Bhullar20-Oct-09 20:10
memberAman Bhullar20-Oct-09 20:10 
AnswerRe: Insert New Row in XML? Pin
Mirko198021-Oct-09 6:32
memberMirko198021-Oct-09 6:32 
QuestionHow to use DbLinq that suport Linq To Oracle? Pin
mehdi talebi20-Oct-09 9:44
membermehdi talebi20-Oct-09 9:44 
AnswerRe: How to use DbLinq that suport Linq To Oracle? Pin
spiritboy15-Dec-09 19:27
memberspiritboy15-Dec-09 19:27 
QuestionLINQ-GRIDVIEW Pin
sris 42620-Oct-09 5:09
membersris 42620-Oct-09 5:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    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
Web03 | 2.8.150427.4 | Last Updated 22 Mar 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid