Click here to Skip to main content
15,892,059 members
Home / Discussions / Visual Basic
   

Visual Basic

 
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 
GeneralRe: Entity Framework : Clone an object and only its childs Pin
dilkonika12-Apr-15 15:05
dilkonika12-Apr-15 15:05 
GeneralRe: Entity Framework : Clone an object and only its childs Pin
Sascha Lefèvre12-Apr-15 23:18
professionalSascha Lefèvre12-Apr-15 23:18 
GeneralRe: Entity Framework : Clone an object and only its childs Pin
dilkonika13-Apr-15 5:04
dilkonika13-Apr-15 5:04 
GeneralRe: Entity Framework : Clone an object and only its childs Pin
Sascha Lefèvre13-Apr-15 5:30
professionalSascha Lefèvre13-Apr-15 5:30 
QuestionEntity Framework : Why this extension is not usable ? Pin
dilkonika10-Apr-15 18:25
dilkonika10-Apr-15 18:25 
Hello !
I'm using entity framework 6 with Vb.net 2013.
I'm trying to add an extension.
This is the code :
Imports System.ComponentModel
Imports System.Collections
Imports System.Data.Entity.Core.Objects.DataClasses
Imports System.Runtime.Serialization
Imports System.IO
Imports System.Reflection

Module Extensions
    <System.Runtime.CompilerServices.Extension> _
    Public Function Clone(Of T As EntityObject)(source As T) As T
        Dim ser = New DataContractSerializer(GetType(T))
        Using stream = New MemoryStream()
            ser.WriteObject(stream, source)
            stream.Seek(0, SeekOrigin.Begin)
            Return CType(ser.ReadObject(stream), T)
        End Using
    End Function
    End Module

But if I try to use like this :
Dim litm, newitm as MyObject
       For Each litm In itemlist
           newitm = litm.Clone()
       ...
       Next

I'm getting this error :
'Clone' is not a member of 'TheProg.MyObject'

What's the problem ?
AnswerRe: Entity Framework : Why this extension is not usable ? Pin
Dave Kreskowiak10-Apr-15 19:56
mveDave Kreskowiak10-Apr-15 19:56 
GeneralRe: Entity Framework : Why this extension is not usable ? Pin
dilkonika10-Apr-15 20:03
dilkonika10-Apr-15 20:03 
GeneralRe: Entity Framework : Why this extension is not usable ? Pin
Dave Kreskowiak10-Apr-15 20:34
mveDave Kreskowiak10-Apr-15 20:34 
GeneralRe: Entity Framework : Why this extension is not usable ? Pin
dilkonika11-Apr-15 5:33
dilkonika11-Apr-15 5:33 
GeneralRe: Entity Framework : Why this extension is not usable ? Pin
Dave Kreskowiak11-Apr-15 7:00
mveDave Kreskowiak11-Apr-15 7:00 
GeneralRe: Entity Framework : Why this extension is not usable ? Pin
dilkonika11-Apr-15 7:34
dilkonika11-Apr-15 7:34 
GeneralRe: Entity Framework : Why this extension is not usable ? Pin
Dave Kreskowiak11-Apr-15 8:32
mveDave Kreskowiak11-Apr-15 8:32 
GeneralRe: Entity Framework : Why this extension is not usable ? Pin
dilkonika11-Apr-15 8:37
dilkonika11-Apr-15 8:37 
GeneralRe: Entity Framework : Why this extension is not usable ? Pin
Dave Kreskowiak12-Apr-15 5:04
mveDave Kreskowiak12-Apr-15 5:04 
GeneralRe: Entity Framework : Why this extension is not usable ? Pin
dilkonika12-Apr-15 17:58
dilkonika12-Apr-15 17:58 
GeneralRe: Entity Framework : Why this extension is not usable ? Pin
Dave Kreskowiak12-Apr-15 18:36
mveDave Kreskowiak12-Apr-15 18:36 
GeneralRe: Entity Framework : Why this extension is not usable ? Pin
dilkonika12-Apr-15 18:39
dilkonika12-Apr-15 18:39 
GeneralRe: Entity Framework : Why this extension is not usable ? Pin
Dave Kreskowiak13-Apr-15 2:57
mveDave Kreskowiak13-Apr-15 2:57 
GeneralRe: Entity Framework : Why this extension is not usable ? Pin
dilkonika13-Apr-15 5:08
dilkonika13-Apr-15 5:08 
GeneralRe: Entity Framework : Why this extension is not usable ? Pin
Dave Kreskowiak13-Apr-15 6:06
mveDave Kreskowiak13-Apr-15 6:06 
GeneralRe: Entity Framework : Why this extension is not usable ? Pin
Sascha Lefèvre13-Apr-15 6:18
professionalSascha Lefèvre13-Apr-15 6:18 
GeneralRe: Entity Framework : Why this extension is not usable ? Pin
dilkonika13-Apr-15 6:26
dilkonika13-Apr-15 6:26 

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.