DO 5.0.18

AsQueryable for Xtensive.Orm.Linq.Grouping lead to exception

Fixing would be preferable or at least more specific exception.

Example

internal class Program
{
    private static void Main(string[] args)
    {
        var dc = new DomainConfiguration("sqlserver", "Data Source=.; Initial Catalog=DO40-Tests; Integrated Security=True;");

        dc.Types.Register(typeof(TestEntity));

        dc.UpgradeMode = DomainUpgradeMode.Recreate;

        using (var d = Domain.Build(dc))
        {
            using (var s = d.OpenSession())
            using (s.Activate())
            using (s.OpenTransaction())
            {
                new TestEntity(s)
                {
                    Name = "test"
                };

                var groups = Query.All<TestEntity>().GroupBy(it => it.Name);

                foreach (var group in groups)
                {
                    _ = group.Select(it => it.Id).ToArray();
                    _ = group.AsEnumerable().Select(it => it.Id).ToArray();
                    _ = group.AsQueryable().Select(it => it.Id).ToArray(); //Exception
                }
            }
        }
    }

    [HierarchyRoot]
    public class TestEntity : Entity
    {
        /// <summary>Initializes a new instance of this class.</summary>
        /// <param name="session">The session.</param>
        public TestEntity(Session session) : base(session)
        {
        }

        [Key]
        [Field(Nullable = false)]
        public int Id { get; private set; }

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

Exception can be different

In test thrown 'Value for parameter 'groupingParameter' is not set.'

In other project thrown 'ArgumentException: must be reducible node'

asked Feb 03 at 07:54

Gushchin%20Anton's gravatar image

Gushchin Anton
11121923

Be the first one to answer this question!
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