With not nullable link field on inherited enities

model:

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

    [Field(Length = 100)]
    public string Text { get; set; }
}

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

    [Field(Length = 100)]
    public string Text { get; set; }
}

public class MyEntityWithLink : MyEntity
{
    [Field(Nullable = false)]
    public SomeEntity link { get; set; }
}

public class MyEntityWithText : MyEntity
{
    [Field]
    public string someData { get; set; }

example data:

var se1 = new SomeEntity { Text = "se1" };
var se2 = new SomeEntity { Text = "se2" };

var mie1 = new MyEntityWithLink { link = se1, Text = "MyEntityWithLink" };
var mie2 = new MyEntityWithLink { link = se2, Text = "MyEntityWithLink" };
var mihe2 = new MyEntityWithText() { someData = "ololo", Text = "MyEntityWithText" };

query with wrong behavior:

// if MyEntityWithLink.SomeEntity - decorated with [Field(Nullable = false)] - there are no MyEntityWithText data
// if MyEntityWithLink.SomeEntity - decorated with [Field(Nullable = true)] - ok
var items = Query.All<MyEntity>().OrderBy(a => a.Id)
    .Select(q =>
            (q as MyEntityWithLink != null)
                ? new { d = (q as MyEntityWithLink).link.Text }
                : new { d = (q as MyEntityWithText).someData });

asked Jan 14 '11 at 03:46

pil0t's gravatar image

pil0t
207575763

edited Jan 14 '11 at 15:37

Alex%20Yakunin's gravatar image

Alex Yakunin
29714412


One Answer:

Hello pil0t,

Thanks for the bug report. We'll investigate the issue shortly (likely, next week).

answered Jan 14 '11 at 07:11

Dmitri%20Maximov's gravatar image

Dmitri Maximov
22111211

The issue is resolved and new binaries will be available soon.

(Jan 22 '11 at 07:11) Alexis Kochetov Alexis%20Kochetov's gravatar image

DataObjects.Net 4.3.7 & 4.4 beta 2 is released

(Jan 29 '11 at 04:23) Dmitri Maximov Dmitri%20Maximov's gravatar image
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA