Datamapper not mapping/skipping property

Datamapper not mapping/skipping property

Old forum URL: forums.lhotka.net/forums/t/6147.aspx


pac posted on Tuesday, January 13, 2009

Hi,

I am having trouble with the datamapper, it won't map one of my properties but maps the rest fine (Including other properties with the same type of Guid?).
The property inside the BO that isn't being updated by the datamapper looks like this

private static PropertyInfo FKNationalityProperty = RegisterProperty(typeof(Person), new PropertyInfo("FKNationality"));
public Guid? FKNationality
{
get { return GetProperty(FKNationalityProperty); }
set { SetProperty(FKNationalityProperty, value); }
}

my ASPX dropdownlist properties look like this

DropDownList ID="DropDownList3" runat="server" AppendDataBoundItems="True"
DataSourceID="DSNationalityList" DataTextField="Value" DataValueField="Key"
SelectedValue='# Bind("FKNationality")'

asp:ListItem Text="Not Selected" Value=""

When I inspect the e.Values I can see the GUID in there against FKNationality, it just doesn't put it to the object.
I have to do something like this to work around it and this works fine.

Csla.Data.DataMapper.Map(e.Values, obj);
if (e.Values["FKNationality"] != null)
{
obj.FKNationality = new Guid(e.Values["FKNationality"].ToString());
}
else
{
obj.FKNationality = null;
}

I have used the datamapper a few times now, each time it has worked perfectly. It may be something I am doing wrong but I cannot see it so far.
Is their any known issues I should be looking out for?
Sorry if there has already been a solution to this in the forum, I did a search and looked around but I couldn't find anything that matched my problem

Copyright (c) Marimer LLC