It can be reproduced on 7524 build, on 7487 everything is ok.
We have:
[Serializable]
[HierarchyRoot(InheritanceSchema = InheritanceSchema.ConcreteTable)]
public abstract class BaseEntity : Entity
{
[Field, Key]
public int Id { get; private set; }
[Field(Nullable = false)]
public int IdSection { get; private set; }
[Field]
public int Num { get; set; }
[Field]
public File File1 { get; set; }
protected BaseEntity(int idSection, string nameAdmin)
{
NameAdmin = nameAdmin;
IdSection = idSection;
}
}
[Serializable]
public class File : Structure
{
[Field]
public string FileName { get; set; }
[Field]
public string Text { get; set; }
[Field]
public string RelativePath { get; set; }
public string AbsolutePath
{
get { return "/" + RelativePath; }
}
}
public class CommonPage : BaseEntity
{
public CommonPage(int idSection, string nameAdmin) : base(idSection, nameAdmin)
{
}
[Field]
public string H1 { get; set; }
[Field]
public File CustomFile { get; set; }
[Field]
public File11 CustomFile11 { get; set; }
}
[Serializable]
public class File11 : Structure
{
[Field]
public string X { get; set; }
}
/ and some code with Structure - null /
var t = Xtensive.Orm.Session.Current.Query.All<commonpage>().FirstOrDefault(z => z.Id == 36);
var t2 = t.CustomFile; // null
var t3 = t.File1; // not NULL
var t4 = t.CustomFile11; //null
BaseEntity and File located in one assembly, and CommonPage and File1 - in another.
So, File field in base class works ok, but in child class - it has Null value.
Update:
Seems, problem is in different assemblies. Even int or string fields can't be saved.
So, here is case: we have base abstract entity class in one assembly, and child concrete class in another assembly.
When trying to read fields of child class we got NULL instead of field values, even if there are some values in database.
And field values exists only in Session/Transaction, and not stored in database.
Genereated code from Reflector:
base class, one assembly
[Serializable, Initializable(AttributeId=-5123476168254685180L, AttributePriority=0x20000000), Display(ChildEntitiesDisplayMode=ChildEntitiesDisplayMode.Entities), HierarchyRoot(InheritanceSchema=2), HasInheritedAttribute(new long[] { -5123476168254685177L })]
public abstract class BaseEntity : Entity
{
// Fields
private List<type> _hierarchy;
private readonly List<pagetemplate> _pageTemplates;
// Methods
[CompilerGenerated]
protected BaseEntity(EntityState arg0);
protected BaseEntity(int idSection, string nameAdmin);
[CompilerGenerated]
protected BaseEntity(SerializationInfo arg0, StreamingContext arg1);
[CompilerGenerated]
protected BaseEntity(Session arg0, EntityState arg1);
.............
public DisplayAttribute GetDisplaySettings();
private void GetHierarchy(BaseEntity entity);
// Properties
public IEnumerable<BaseEntity> ChildEntities { get; }
[Field]
private EntitySet<BaseEntity> ChildEntitySet { [CompilerGenerated, CompilerGenerated, DebuggerNonUserCode] get; [CompilerGenerated, DebuggerNonUserCode, CompilerGenerated] set; }
[Field]
public File File1 { [DebuggerNonUserCode, CompilerGenerated, CompilerGenerated] get; [DebuggerNonUserCode, CompilerGenerated, CompilerGenerated] set; }
public IEnumerable<Type> Hierarchy { get; }
[Field, Key]
public int Id { [CompilerGenerated, DebuggerNonUserCode, CompilerGenerated] get; [CompilerGenerated, CompilerGenerated, DebuggerNonUserCode] private set; }
[Field(Nullable=false)]
public int IdSection { [CompilerGenerated, CompilerGenerated, DebuggerNonUserCode] get; [DebuggerNonUserCode, CompilerGenerated, CompilerGenerated] private set; }
[ModelField(Label="Главная страница шаблона", ModelFieldType=ModelFieldType.Checkbox, PropertyName="IsMainInSection", ValueType=typeof(bool), Group=Group.Core), Field]
public bool IsMainInSection { [CompilerGenerated, CompilerGenerated, DebuggerNonUserCode] get; [CompilerGenerated, DebuggerNonUserCode, CompilerGenerated] set; }
[Field, ModelField(Label="Видима", ModelFieldType=ModelFieldType.Checkbox, PropertyName="IsVisible", ValueType=typeof(bool), Group=Group.Core)]
public bool IsVisible { [CompilerGenerated, CompilerGenerated, DebuggerNonUserCode] get; [CompilerGenerated, CompilerGenerated, DebuggerNonUserCode] set; }
[Field]
public int ListItemTemplateId { [DebuggerNonUserCode, CompilerGenerated, CompilerGenerated] get; [CompilerGenerated, DebuggerNonUserCode, CompilerGenerated] set; }
[Field]
public int ListTemplateId { [CompilerGenerated, CompilerGenerated, DebuggerNonUserCode] get; [CompilerGenerated, DebuggerNonUserCode, CompilerGenerated] set; }
......................
// Nested Types
[DebuggerNonUserCode, CompilerGenerated]
internal sealed class <>z__Aspects
{
// Fields
internal static Type _1;
internal static LocationInfo _10;
internal static LocationInfo _11;
internal static LocationInfo _12;
internal static LocationInfo _13;
internal static LocationInfo _14;
..............
// Methods
[CompilerGenerated]
static <>z__Aspects();
}
}
Code from child file (another assembly)
[Initializable(AttributeId=-5123476168254685180L, AttributePriority=0x30000000), HasInheritedAttribute(new long[] { -5123476168254685177L })]
public class CommonPage : BaseEntity
{
// Methods
[CompilerGenerated]
protected CommonPage(EntityState arg0);
public CommonPage(int idSection, string nameAdmin);
[CompilerGenerated]
protected CommonPage(SerializationInfo arg0, StreamingContext arg1);
[CompilerGenerated]
protected CommonPage(Session arg0, EntityState arg1);
[DebuggerNonUserCode, CompilerGenerated]
private static CommonPage ~Xtensive.Aspects.FactoryMethod(EntityState arg0);
[DebuggerNonUserCode, CompilerGenerated]
private static CommonPage ~Xtensive.Aspects.FactoryMethod(SerializationInfo arg0, StreamingContext arg1);
[DebuggerNonUserCode, CompilerGenerated]
private static CommonPage ~Xtensive.Aspects.FactoryMethod(Session arg0, EntityState arg1);
// Properties
[ModelField(Label="Файл", ModelFieldType=ModelFieldType.File, PropertyName="CustomFile", Group=Group.Specific), Field]
public File CustomFile { get; set; }
[Field, Preview(Quality=10), ModelField(Label="Картинка", ModelFieldType=ModelFieldType.File, PropertyName="CustomPhoto", Group=Group.Specific), Preview(Width=300, Heigth=300, Quality=50, FolderName="p2")]
public Photo CustomPhoto { get; set; }
[ModelField(Label="H1", PropertyName="H1", Group=Group.Specific), Field]
public string H1 { get; set; }
// Nested Types
[DebuggerNonUserCode, CompilerGenerated]
internal sealed class <>z__Aspects
{
// Fields
internal static Type _1;
// Methods
[CompilerGenerated]
static <>z__Aspects();
}
}
So, assembly with child class have been processed correctly, but fields have not been processed.
Ness, thanks for the code sample. I'll check this right after the issue with SQL Server CE
Problem is in different assemblies. Even int or string fields can't be saved.
So, here is case: we have base abstract entity class in one assembly, and child concrete class in another assembly.
When trying to read fields of child class we got NULL instead of field values, even if there are some values in database.
And field values exists only in Session/Transaction, and not stored in database.