I'm sure I'm missing something but I'm not sure what it is.
Business.dll
[Serializable()]
[Csla.Server.ObjectFactory("DataAccess.MenuItemFactory, DataAccess")]
public class MenuItem : BusinessBase<MenuItem>
{
public static PropertyInfo<string> DescriptionProperty =
RegisterProperty<string>(m => m.Description);
private string _description = DescriptionProperty.DefaultValue;
public string Description{
get { return GetProperty(DescriptionProperty, _description);}
set { SetProperty(DescriptionProperty, ref _description, value); }}
}
DataAccess.dll
public class MenuItemFactory : ObjectFactory
{
public MenuItem Fetch(SingleCriteria<MenuItem, int> criteria)
{
var efMenuItem = context.MenuItem... // Entity Framework to SQL DB query
MenuItem menuItem = (MenuItem)Activator.CreateInstance(typeof(MenuItem), true);
LoadProperty(menuItem, MenuItem.DescriptionProperty, efMenuItem.Description);
MarkOld(menuItem);
return menuItem
}
}
From a console app that references both these projects
MenuItem menuItem = MenuItem.GetMenuItem(1);
At this point menuItem.Description is empty string. It should not be.
Using debug I’ve confirmed that in MenuItemFactor.Fetch efMenuItem.Description has a value at the time the LoadProperty method is called however GetMenuItem returns a MenuItem with an empty Description. What am I missing?
Well, BypassPropertyChecks is a property on the BO instance you're trying to load. So usually its using ( menuitem.ByPassPropertyChecks ) { // load here }.
Copyright (c) Marimer LLC