Esempio n. 1
0
        public void OrderBySubQuery([DataSources(ProviderName.SqlCe)] string context)
        {
            var testData = GetTestData();

            using (var db = GetDataContext(context))
                using (var table = db.CreateLocalTable(testData))
                {
                    var subQuery1 =
                        table.OrderBy(t => t.OrderData1)
                        .Select(c => new OrderByDistinctData
                    {
                        Id            = c.Id * 1,
                        DuplicateData = c.DuplicateData,
                        OrderData1    = c.OrderData1,
                        OrderData2    = c.OrderData2
                    });

                    var subQuery2 =
                        subQuery1.OrderBy(t => t.OrderData1);

                    var query = from t in table.Take(2)
                                orderby t.Id descending
                                select new
                    {
                        t.DuplicateData,
                        Count = subQuery2.Where(s => s.DuplicateData == t.DuplicateData).Count()
                    };

                    var selectQuery = query.GetSelectQuery();
                    var info        = new QueryInformation(selectQuery);
                    info.GetParentQuery(selectQuery);

                    var result = query.ToArray();
                }
        }