score:1

Accepted answer

You can do that with a UNION query. EG

var q = db.Books.GroupBy(g => "Books").Select(g => new { Name = g.Key, EntryCount = g.Count() })
          .Union(db.Authors.GroupBy(g => "Authors").Select(g => new { Name = g.Key, EntryCount = g.Count() }));

var r = q.ToList();

score:1

Not an EF guy, and not sure if this would be more performant.

Select TableName = o.name
      ,RowCnt    = sum(p.Rows)
  From sys.objects    as o
  Join sys.partitions as p on o.object_id = p.object_id
 Where o.type = 'U'
   and o.is_ms_shipped = 0x0
   and index_id < 2  -- 0:Heap, 1:Clustered
   --and o.name in ('Table1','Table2','Table3' )   -- Include (or not) your own filter
Group By o.schema_id,o.name

Note: Wish I could recall the source of this, but I've used it in my discovery process.


Related Query

More Query from same tag