This is a migrated thread and some comments may be shown as answers.

How to extend a Class

11 Answers 246 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
test
Top achievements
Rank 1
test asked on 31 Jul 2010, 11:29 PM
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.
 

11 Answers, 1 is accepted

Sort by
0
PetarP
Telerik team
answered on 02 Aug 2010, 01:17 PM
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
0
test
Top achievements
Rank 1
answered on 02 Aug 2010, 10:14 PM
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.
0
Rok
Top achievements
Rank 2
answered on 03 Aug 2010, 08:34 AM
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
0
test
Top achievements
Rank 1
answered on 03 Aug 2010, 07:36 PM
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...

0
test
Top achievements
Rank 1
answered on 05 Aug 2010, 06:03 AM
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
0
Accepted
Serge
Telerik team
answered on 05 Aug 2010, 05:37 PM
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
0
Shawn Krivjansky
Top achievements
Rank 1
answered on 27 Aug 2010, 10:05 PM
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...
0
Alexander
Telerik team
answered on 30 Aug 2010, 08:10 AM
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
0
Serge
Telerik team
answered on 14 Oct 2010, 04:58 PM
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
0
Shawn Krivjansky
Top achievements
Rank 1
answered on 16 Nov 2010, 10:56 PM

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

0
Serge
Telerik team
answered on 18 Nov 2010, 07:26 PM
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.
Tags
General Discussions
Asked by
test
Top achievements
Rank 1
Answers by
PetarP
Telerik team
test
Top achievements
Rank 1
Rok
Top achievements
Rank 2
Serge
Telerik team
Shawn Krivjansky
Top achievements
Rank 1
Alexander
Telerik team
Share this question
or