How to extend a Class

12 posts, 1 answers
  1. test
    test avatar
    27 posts
    Member since:
    Feb 2008

    Posted 31 Jul 2010 Link to this post

    Hi,

    I have a table "Users", in my domain model I've a class "User" mapped to this table. In my "Users" table I've 2 fields : FirstName and LastName. In my class I would create a new property called DisplayName wich would be the concatenation of the properties FirstName and LastName.

    How can I do that ?

    Here's what I have tried :
    . I create a partial class with "DisplayName" property (readonly)
    . I create a new user
    . I had the new user to my openaccesscontext object, and this error appear : Internal error: struct slot access (provideField_invalidSlotNumber, slot=-1)

    What's wrong ?

    Here's my code :

                Using oContext As New MyContext
                    Dim oUser As New User
                    With oUser
                        .FirstName="FirstName"
                        .LastName="LastName"
                    End With
                    oContext.Add(oUser)     <--------- Error
                    oContext.SaveChanges()
                End Using

    Here's my partial class :

    Partial Class User

        Private _displayName As string
        Public Overridable ReadOnly Property DisplayName As string
            Get
                Return _firstName & " " & _lastName
            End Get
        End Property

    End Class



    Please help.
     
  2. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 02 Aug 2010 Link to this post

    Hi test,

     We tried the same setup as you have provided but we could not reproduce this false behavior. If you are willing to send us a small project that reproduces the behavior I will gladly convert the conversation to one that allows attachments.
    We are looking forward to your reply.

    Kind regards,
    Petar
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
  4. test
    test avatar
    27 posts
    Member since:
    Feb 2008

    Posted 02 Aug 2010 Link to this post

    Hi,

    I was trying to isolate my problem in a small project without success until moment I declared a private variable in my partial class. In my exemple if you suppress "_displayname" private variable the problem disapear.

    When you try to reproduce my problem do you declare this private variable in your partial class ?

    The problem is that I need this private variable because in my final solution I don't need a readonly property in my partial class but a read/write property. How can I do this ?

    Thanks for your help.
  5. Rok
    Rok avatar
    20 posts
    Member since:
    Apr 2008

    Posted 03 Aug 2010 Link to this post

    Hi

    I stumbled on the same error "Internal error: struct slot access (provideField_invalidSlotNumber, slot=-1)".

    I deleted entity from the model designer and drag and droped it again into it to solve the problem.

    Hope it helps.

    Rok
  6. test
    test avatar
    27 posts
    Member since:
    Feb 2008

    Posted 03 Aug 2010 Link to this post

    I delete the entity from the model designer, I drag and drop the table to recreate the entity and I've have always the same error.

    Please help...

  7. test
    test avatar
    27 posts
    Member since:
    Feb 2008

    Posted 05 Aug 2010 Link to this post

    Perhaps Telerik Team have a simple example of what i'm trying to do. Finally I'm trying to do something simple that everobody seems to do : A entity map with a table, extended by a partial class with a new property wich is not persist in database. Somebody have an example wich is working ?

    Thanks
  8. Answer
    Serge
    Admin
    Serge avatar
    375 posts

    Posted 05 Aug 2010 Link to this post

    Hi test,

     After debugging and researching your problem we have found out what the issue is. The runtime system picks up fields that you have defined in the partial and marks them as persistent. This is in fact a bug and we will be working on fixing this. However there is a small and easy fix you can do in order to get things working, at least for now.

    What you need to do is mark the field you define in the partial with the Transient attribute (it is located in the Telerik.OpenAccess namespace). I have tested this out and it seems to be the solution to your problem. 

    Sorry for the inconvenience caused. Please do find your Telerik points updated for reporting this issue and do not hesitate to contact us back if you face further trouble.

    Kind regards,
    Serge
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  9. Shawn Krivjansky
    Shawn Krivjansky avatar
    86 posts
    Member since:
    Jan 2010

    Posted 27 Aug 2010 Link to this post

    Would it be possible to notify via this thread when this is fixed?

    It's slightly annoying to not be able to use auto-properties (in VB) because of this.
    For example (and for other's benefit):
    I CANNOT use:
    <Transient()> _
    Public Property RateCheck As String = String.Empty

    I must use:
    <Transient()> _
    Private _RateCheck As String
    <Transient()> _
    Public Property RateCheck() As String
        Get
            Return _RateCheck
        End Get
        Set(ByVal value As String)
            _RateCheck = value
        End Set
    End Property

    At least that is the only way I was able to get it to work...
  10. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 30 Aug 2010 Link to this post

    Hello Shawn,

    Sure, we will update the thread once this is fixed.

    Greetings,
    Alexander
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  11. Serge
    Admin
    Serge avatar
    375 posts

    Posted 14 Oct 2010 Link to this post

    Hello Shawn Krivjansky,

    The issue is fixed and the solution can be found in the internal build released yesterday. Note that you will have to be logged in, in order to download it.

    Best wishes,
    Serge
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  12. Shawn Krivjansky
    Shawn Krivjansky avatar
    86 posts
    Member since:
    Jan 2010

    Posted 16 Nov 2010 Link to this post

    I have tested this with the new 2010 Q3 release.

    Looks like it still isn't working.  I am getting an error when my partial class is accessed:
    "Invalid column name '_add_on_check'.  Invalid column name '_container_check'.  Invalid column name '_g_l_code_check'.  Invalid column name '_order_ref_check'.  Invalid column name '_price_check'.  Invalid column name '_quantity_check'.  Invalid column name '_rate_check'.  Invalid column name '_un_matched_check'.  Invalid column name '_weight_check'.  Statement(s) could not be prepared."

    This is a result of thie partial class that seems to cause this error:

    Partial Public Class TMDiscrepancyHeader
        <Transient()> _
        Public Property RateCheck As String = String.Empty
        <Transient()> _
        Public Property WeightCheck As String = String.Empty
        <Transient()> _
        Public Property ContainerCheck As String = String.Empty
        <Transient()> _
        Public Property OrderRefCheck As String = String.Empty
        <Transient()> _
        Public Property GLCodeCheck As String = String.Empty
      
        <Transient()> _
        Public Property PriceCheck As String = String.Empty
        <Transient()> _
        Public Property QuantityCheck As String = String.Empty
        <Transient()> _
        Public Property UnMatchedCheck As String = String.Empty
        <Transient()> _
        Public Property AddOnCheck As String = String.Empty

    I thought things were fixed with regard to this??

    If I use the following syntax...things work:
    <Transient()> _
    Private _RateCheck As String
    <Transient()> _
    Public Property RateCheck() As String
        Get
            Return _RateCheck
        End Get
        Set(ByVal value As String)
            _RateCheck = value
        End Set
    End Property

  13. Serge
    Admin
    Serge avatar
    375 posts

    Posted 18 Nov 2010 Link to this post

    Hello Shawn Krivjansky,

     I am sorry for the misunderstanding, after debugging we have found out that you are using attributes mapping in for your model. It turns out that we have another bug here, however we have it planned for improvement and the issue will be fixed. I will notify you (again) in this thread when the issue is resolved.

    However for the time being you can either switch to XML mapping or continue using the workaround you previously found.

    I hope this is helpful. 

    All the best,
    Serge
    the Telerik team
    Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
Back to Top
DevCraft banner