views:

9

answers:

0

hi there i design a multilayer we appliction andusing LINQ a my data provider i need to user my own Entites instead o LINQ etities. so i created Entities Project and create my entities in it.

when i get data from contex and cast them to my entities , everything is ok. but when i want to cast on of my entities to linq entity , an exception thrown.

in my linq entity i add CTYPE operator from and to my entities

Exp :

Public Class BaseController(Of LinqEntity As {BaseEntity, New}, MyEntity As ModuleEntities.BaseEntityInfo)
Implements Interfaces.Base(Of ServiceEntity)

'This methd work fine and cast LinqEntity to MyEntity
Public Function GetAll() As List(Of MyEntity ) 
    Dim q = (From x In Context.GetTable(Of LinqEntity)() _
             Select x).Cast(Of MyEntityBase)
End Function

Public Sub Update(ByVal entity As MyEntity) 

    'here is problem
    'cast , direct cast , or anything not work
    Dim x as LinqEntity = entity
    Me.Context.GetTable(Of LinqEntity).InsertOnSubmit(entity)
    Me.Context.SubmiChanges()

End Sub