google-code-export / dataobjectsdotnet

Automatically exported from code.google.com/p/dataobjectsdotnet
0 stars 0 forks source link

Generic Structure descendants aren't supported (2 bugs) #785

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Subj.

Model:

  [Serializable]
  [HierarchyRoot]
  public class Book : Entity
  {
    [Key, Field]
    public int Id { get; private set; }

    [Field]
    public string Title { get; set; }

    [Field]
    public RefHolder<Book> BookRef { get; set; }

    public override string ToString()
    {
      return Title;
    }
  }

  [Serializable]
  public class RefHolder<T> : Structure
  {
    public T Ref { get; set; }
  }

To build domain with this model, we should currently use this code:

    protected override DomainConfiguration BuildConfiguration()
    {
      var configuration = base.BuildConfiguration();
      configuration.Types.Register(typeof(Book).Assembly, typeof(Book).Namespace);
      // !!! WHY THIS IS NECESSARY? !!!
      configuration.Types.Register(typeof(RefHolder<Book>));
      return configuration;
    }

If we don't explicitly register typeof(RefHolder<Book>), an exception is thrown 
by model inspector saying "type ... isn't registered".

This must be fixed.

Original issue reported on code.google.com by alex.yakunin on 20 Aug 2010 at 7:44

GoogleCodeExporter commented 9 years ago
Forgot to add [Field] to Ref property. 

But after testing noticed this doesn't change anything.

Original comment by alex.yakunin on 20 Aug 2010 at 8:10

GoogleCodeExporter commented 9 years ago
Ups, WORSE: it simply fails in this case (model inspector says "unsupported 
field type T").

I created test for both bugs (Issue0785_GenericStructureBugs):
1) Bug with automatic registration
2) Bug with generic field in structure.

Original comment by alex.yakunin on 20 Aug 2010 at 8:21

GoogleCodeExporter commented 9 years ago

Original comment by alexis.k...@gmail.com on 23 Aug 2010 at 3:39

GoogleCodeExporter commented 9 years ago

Original comment by Dmitri.Maximov on 23 Aug 2010 at 1:13

GoogleCodeExporter commented 9 years ago
See updated model:
http://support.x-tensive.com/question/3029/refholder-is-not-registered-in-the-mo
del

Original comment by Dmitri.Maximov on 16 Sep 2010 at 7:48

GoogleCodeExporter commented 9 years ago

Original comment by Dmitri.Maximov on 17 Sep 2010 at 1:51

GoogleCodeExporter commented 9 years ago

Original comment by Dmitri.Maximov on 24 Sep 2010 at 11:08