Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

grouping with remote grouping for join not working

See original GitHub issue


I am using LinqToDb as database framework (if you use it you don’t want to use EF again 😃 ). Everything works fine for a normal query with a dx-grid. Buit if I try to create a left join query and access the header filter, the created query will fail.

This is my join:

var r = from k in this.GetTable<Person>() join ks in this.GetTable<Student>() on new Tuple<int, string>(k.Id, k.Number.ToString()) equals
               new Tuple<int, string>(ks.Id, ks.Number) into joinedTable
               from g in joinedTable.DefaultIfEmpty()
                    select new Person(k) {
            IsBlocked = (k.StatusBitmask & 0x80) != 0, IsBlockedStudent = (g.StatusBitmask & 0x80) != 0 };

The reault in the grid works perfect:

      public HttpResponseMessage GetFiltered( [FromUri]DataSourceLoadOptions loadOptions)
         LoadResult result = null;
            loadOptions.RemoteSelect = true;
            loadOptions.RequireTotalCount = true;
            using(var db = DbContext())
               // Get joined result will retrieve the joined query.
               result = DataSourceLoader.Load(db.GetJoinedResult(), loadOptions);
         catch (Exception ex)
            return new HttpResponseMessage(HttpStatusCode.InternalServerError);
         return Request.CreateResponse(result);

The resulting sql is the following:

-- Firebird
	Count(*) as c1,
	0 as c2
		LEFT JOIN STUDENT joinedTable ON k1.ID = joinedTable.ID AND Cast(k1.NUMBER as VarChar(11) CHARACTER SET UNICODE_FSS) = joinedTable.NUMBER

This does not work, because the order by is not valid. And I am not sure if this is the desired query?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

frankiDotNetcommented, Apr 9, 2018

Checked this with the guys at LinqToDb. It is the cause of using the copy constructor in the GetJoinedResult(), so the grouping had no data to group. Without using a copy constructor, but setting the properties directly in the select statement, this works. Thanks for your work!

frankiDotNetcommented, Apr 5, 2018

Nit 100% sure, but this could be a linq2db bug.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Not able to use GROUP BY with join query in MySQL
1 Answer 1 ... You can not select all(* means all) columns from a table and do a group by one column. That...
Read more >
Group By with Inner Joins. This is not working. : r/SQL
Hi Everyone, I am playing around with the group by clause to get a better understanding of how it works. I am working...
Read more >
DataGrid - How to correctly setup remote grouping in ...
We have a problem with grouping in data grid. Remote grouping works if we set autoExpandGroup property to true for all columns.
Read more >
How to Join a Window Covering to a Group - Hunter Douglas
View this video to learn more about programing your Hunter Douglas PowerView Pebble Remote and how to join a window covering to a...
Read more >
Students can't join a group or topic
"Brand New Group" error: The group doesn't have topics yet. For students to join the discussion, educators must add a topic to the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found