This project is read-only.

Bug when using embedded entities

May 24, 2011 at 10:40 AM
Edited May 24, 2011 at 10:42 AM


When using embedded entities in a user control it seems there's a bug which indicates the embedded entity as modified even if it's not. It happens when the ToStr is set for the Embedded Entity. This causes the selfModified boolean to be set.


With kind regards,

Marcel Numeijer.



May 24, 2011 at 3:58 PM


Mmmm... it doesn't make a lot of sense since EmbeddedEntities have no ToStr.

We have a similar error some time before cause PreSaving set ToStr property instead of toStr, but i think you have a newer version that behaves ok. 

Could you clarify this?


In the long run, we will probably allow you to substitute ToString method by an expression, so it works on queries as well and we save the column.

Jun 19, 2012 at 10:48 AM

I ha ve the same problem:

if I change a value of an EmbeddedEntity and I click the Save button, no changes are made.

I use SF2.


Jun 19, 2012 at 1:08 PM

The problem that Marcel encountered is already solved. I think yours is a different one. 

I will need more information, could you paste the code for your entities/xaml?


Jun 19, 2012 at 5:06 PM


I've used the Shop example.

Here is my new class:

    public class AddressDN : EmbeddedEntity
        [SqlDbType(Size = 100)]
        string address;
        [StringLengthValidator(AllowNulls = true, Max = 100)]
        public string Address
            get { return address; }
            set { Set(ref address, value, () => Address); }

        [SqlDbType(Size = 100)]
        string state;
        [StringLengthValidator(AllowNulls = true, Max = 100)]
        public string State
            get { return state; }
            set { Set(ref state, value, () => State); }

In CustomerDN now I have:

        AddressDN address;
        public AddressDN Address
            get { return address; }
            set { Set(ref address, value, () => Address); }

Company.xaml is autogenerated:

<UserControl x:Class="Shop.Windows.Controls.Company"
        <m:ValueLine m:Common.Route="CompanyName" />
        <GroupBox Header="Address" m:Common.Route="Address">
                <m:ValueLine m:Common.Route="Address" />
                <m:ValueLine m:Common.Route="State" />
        <m:ValueLine m:Common.Route="Phone" />
        <m:ValueLine m:Common.Route="EMail" />


Same as Person.xaml.


Any changes in Address or State fields says "There are no changes"


Jun 20, 2012 at 8:23 AM

I've been trying to reproduce the problem on Southwind using an embedded StackPanel, GroupBox and a separated Address control. All of them work. 

Try the following: 

* If you place a breakpoint in the set part of the State property, gets called when you change the value in the user interface? 
* Is the AddressDN SelfMofidied field set to true after the set gets called?

and, just in case, have you seen in the output window any WPF binding problem ? 

Hope it helps. 



Jun 20, 2012 at 10:08 AM

I've tried to upgrade from github also.

The  breakpoint in the set part of the State property does nothing, while on Phone property works instead.

In the Output Window I've got only 2 types of error:

 - "A first chance exception of type 'System.Xml.XmlException' occurred in System.Xml.dll. System.Xml.XmlException was unhandled".

 - "Name cannot begin with the '<' character, hexadecimal value 0x3C."

 - "Could not load file or assembly 'Signum.Windows.Aero, Version=, Culture=neutral, PublicKeyToken=null' or one of its dependencies"

If this can help you, I use italian language.

Jun 20, 2012 at 4:30 PM
Edited Jun 20, 2012 at 4:31 PM

EUREKA! If the breakpoint is not being triggered its because the Address entity is not being instantiated.

Since the template creates a plain StackPanel, you have to instantiate the Address yourself.

Two options:

Nullable Address:
If the address is optional and you want to have the concept of null address (different than all the fields being null) then substitute the control using an EntityDetail or an EntityLine

Non-Nullable Address:
Add a constructor on App.xaml like this. 

Constructor.Register(win => new PersonDN
                Address = new AddressDN()

In this case, its also good to add a NotNullable attribute on AddresDN address field.

Hope it's solved. 

BTW: We all were on Capri last week for a wedding :)

Jun 20, 2012 at 5:23 PM

I'll try as soon as possible. Thanks in advance. Good look!

Jun 23, 2012 at 7:30 PM

Wow! It works now. I had to manually delete the "Address_HasValue" field width MS Sql Server Management studio, because, after upgrade, Shop.Load don't provide by itself.

Regards to all the team!

Jun 26, 2012 at 8:38 AM

Good that it worked! Really odd that the synchronizer didn't remove the field though.