Click here to Skip to main content
15,909,051 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: HashSet(Of T) - how can I get elements by position number ? Pin
dilkonika15-Apr-15 11:53
dilkonika15-Apr-15 11:53 
GeneralRe: HashSet(Of T) - how can I get elements by position number ? Pin
Sascha Lefèvre15-Apr-15 12:31
professionalSascha Lefèvre15-Apr-15 12:31 
GeneralRe: HashSet(Of T) - how can I get elements by position number ? Pin
dilkonika15-Apr-15 12:59
dilkonika15-Apr-15 12:59 
GeneralRe: HashSet(Of T) - how can I get elements by position number ? Pin
Sascha Lefèvre15-Apr-15 13:24
professionalSascha Lefèvre15-Apr-15 13:24 
GeneralRe: HashSet(Of T) - how can I get elements by position number ? Pin
dilkonika15-Apr-15 13:50
dilkonika15-Apr-15 13:50 
GeneralRe: HashSet(Of T) - how can I get elements by position number ? Pin
Sascha Lefèvre15-Apr-15 14:20
professionalSascha Lefèvre15-Apr-15 14:20 
GeneralRe: HashSet(Of T) - how can I get elements by position number ? Pin
dilkonika15-Apr-15 15:55
dilkonika15-Apr-15 15:55 
GeneralRe: HashSet(Of T) - how can I get elements by position number ? Pin
Sascha Lefèvre16-Apr-15 7:24
professionalSascha Lefèvre16-Apr-15 7:24 
dilkonika wrote:
and this code is not using CTypeDynamic.
Because it works without it. For completeness, I included the analog into the VB-version:
VB
Public Class ChildClass
End Class

Public Class SomeClass
    Public Property Children As ICollection(Of ChildClass) = New HashSet(Of ChildClass)
End Class

Public Function CopyEntity(Of T As {Class, New})(entity As T) As T
    Dim clone As New T()
    Return clone
End Function

Sub Main()
    Dim someClass = New SomeClass
    someClass.Children.Add(New ChildClass)

    Dim el = Enumerable.ElementAt(CallByName(someClass, "Children", CallType.Get), 0)

    Dim elcopy = CopyEntity(el)   REM without CTypeDynamic. doesn't work. (elcopy is Object)

    Dim el1 = CType(el, ChildClass)
    Dim el1copy = CopyEntity(el1) REM works (el1copy is ChildClass)

    Dim el2 = CTypeDynamic(Of ChildClass)(el)
    Dim el2copy = CopyEntity(el2) REM works (el2copy is ChildClass)

    Dim el3 = CTypeDynamic(el, GetType(ChildClass))
    Dim el3copy = CopyEntity(el3) REM doesn't work (el3copy is Object)
End Sub


Quote:
and on my vb.net code , the error came up on the line :
Dim en = ctx.Entry(clone)
and you don't have a such line in your code.
Because the reason why it not works (when it not works) is because clone is of type Object and not of type ChildClass. So I only have to check for the type of clone to know if your line ctx.Entry(clone) would work.

dilkonika wrote:
Also I try to implement your version with reflection , but I can't make it work on vb.net ? can you provide some more
help ?
Please post what you have so far.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

GeneralRe: HashSet(Of T) - how can I get elements by position number ? Pin
dilkonika16-Apr-15 7:32
dilkonika16-Apr-15 7:32 
GeneralRe: HashSet(Of T) - how can I get elements by position number ? Pin
Sascha Lefèvre16-Apr-15 8:16
professionalSascha Lefèvre16-Apr-15 8:16 
GeneralRe: HashSet(Of T) - how can I get elements by position number ? Pin
dilkonika16-Apr-15 8:26
dilkonika16-Apr-15 8:26 
GeneralRe: HashSet(Of T) - how can I get elements by position number ? Pin
Sascha Lefèvre16-Apr-15 8:36
professionalSascha Lefèvre16-Apr-15 8:36 
Questionwhy this code doesn't work ? Pin
dilkonika13-Apr-15 6:20
dilkonika13-Apr-15 6:20 
AnswerRe: why this code doesn't work ? Pin
Sascha Lefèvre13-Apr-15 13:56
professionalSascha Lefèvre13-Apr-15 13:56 
GeneralRe: why this code doesn't work ? Pin
dilkonika13-Apr-15 14:11
dilkonika13-Apr-15 14:11 
GeneralRe: why this code doesn't work ? Pin
Sascha Lefèvre13-Apr-15 15:37
professionalSascha Lefèvre13-Apr-15 15:37 
GeneralRe: why this code doesn't work ? Pin
Sascha Lefèvre14-Apr-15 12:56
professionalSascha Lefèvre14-Apr-15 12:56 
QuestionEntity Framework : Clone an object and only its childs Pin
dilkonika11-Apr-15 17:47
dilkonika11-Apr-15 17:47 
AnswerRe: Entity Framework : Clone an object and only its childs Pin
Sascha Lefèvre11-Apr-15 21:02
professionalSascha Lefèvre11-Apr-15 21:02 
GeneralRe: Entity Framework : Clone an object and only its childs Pin
dilkonika12-Apr-15 11:32
dilkonika12-Apr-15 11:32 
GeneralRe: Entity Framework : Clone an object and only its childs Pin
Sascha Lefèvre12-Apr-15 11:40
professionalSascha Lefèvre12-Apr-15 11:40 
GeneralRe: Entity Framework : Clone an object and only its childs Pin
dilkonika12-Apr-15 11:38
dilkonika12-Apr-15 11:38 
GeneralRe: Entity Framework : Clone an object and only its childs Pin
Sascha Lefèvre12-Apr-15 12:09
professionalSascha Lefèvre12-Apr-15 12:09 
GeneralRe: Entity Framework : Clone an object and only its childs Pin
dilkonika12-Apr-15 13:26
dilkonika12-Apr-15 13:26 
GeneralRe: Entity Framework : Clone an object and only its childs Pin
Sascha Lefèvre12-Apr-15 14:39
professionalSascha Lefèvre12-Apr-15 14:39 

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.