I have the following code:

http://pastebin.com/442Ew49i

This creates a line in my 'Persons' table where Name is NULL but id has a value.

Any idea's?

asked Oct 07 '10 at 10:03

Michiel%20Alders's gravatar image

Michiel Alders
506710

edited Oct 08 '10 at 07:11

When i add the DefaultValueAttribute the DefaultValue is saved to the database. Still not the .Name = "John" value.

(Oct 07 '10 at 10:38) Michiel Alders Michiel%20Alders's gravatar image

2 Answers:

You must use

Otherwise DataObjects.Net won't have a chance to intercept property access operation.

An example of manually defined persistent property in C#:

[Field]
public string Title {
  get { return GetProperty<string>("Title"); }
  set { SetProperty("Title", value); }
}

So you shouldn't declare backing fields as well.

P.S. When auto-property is used, its getter and setter are overwritten by PostSharp by absolutely the same way - this is easy to check using e.g. RedGate .NET Reflector.

answered Oct 07 '10 at 10:49

Alex%20Yakunin's gravatar image

Alex Yakunin
29714412

edited Oct 07 '10 at 10:53

Auto-properties aren't an option. I'm using .NET Framework 3.5. I'll implement the GetFieldValue and SetFieldValue functionalities. Working like a charm.

(Oct 07 '10 at 10:55) Michiel Alders Michiel%20Alders's gravatar image

Oh, quite quick response ;) Btw, VB10 \ VS2010 can target .NET 3.5 (may be this will be helpful).

(Oct 07 '10 at 10:59) Alex Yakunin Alex%20Yakunin's gravatar image

I'll keep that in mind, got it installed anyway. Thanks

(Oct 07 '10 at 12:12) Michiel Alders Michiel%20Alders's gravatar image

I tried the same thing in VB10/VS2010 but the same problem occured.

My Class:

<HierarchyRoot()> _
<TableMapping("Projects")> _
Public Class Project
    Inherits Entity

    Public Sub New()
        MyBase.New()
    End Sub

    Private _Id As Integer
    <Key(), Field()> _
    Public Property ID As Integer
        Get
            Return GetFieldValue(Of Integer)("ID")
        End Get
        Private Set(ByVal value As Integer)
            SetFieldValue(Of Integer)("ID", value)
        End Set
    End Property

    <Field()> _
    Public Property Name As String

    <Field()> _
    Public Property Description As String

End Class

Field is entered correctly, also on Query.All(Of Project), but Name and Description remain 'Nothing'.

answered Oct 08 '10 at 07:09

Michiel%20Alders's gravatar image

Michiel Alders
506710

Likely, there is a bug related to VB.NET auto property recognition by our aspects - there are no automatic tests for DO4 on VB.NET, so it isn't a VB.NET-friendly, and that's mentioned in manual; but we're ready to fix all the issues related to VB.NET support ASAP. We don't expect any really blocking ones - we were supporting VB.NET in previous version of DO (v3.X), so we're aware about differences.

Issue 829 is created. We'll try to fix it in several days.

(Oct 08 '10 at 07:18) Alex Yakunin Alex%20Yakunin's gravatar image
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

Subscription:

Once you sign in you will be able to subscribe for any updates here

Tags:

×574
×4
×2

Asked: Oct 07 '10 at 10:03

Seen: 4,053 times

Last updated: Oct 08 '10 at 07:21

powered by OSQA