I have a LINQ query that I need to rewrite in TSQL to understand why it's pulling duplicate data. However, I'm not able to actually run the code so I have to do it by just looking at the LINQ.
Since you can use JOIN in LINQ, I'm not sure what's going on with these 2 FROMs.
When I try to write a query to pull this data, I am not getting any duplicates -- yet when the code runs, it is failing on a SingleOrDefault call for duplicate data.
var myQ = from T in context.TableModels
          .Where(T => T.ID == 'ID')
        from C in context.ChairModels
         .Where(C => C.TableID == T.ID && C.TableKey == T.TableKey)
       .DefaultIfEmpty()
    select new
     {
       ...
      };
SingleOrDefault is called elsewhere and uses a key to select the 1 record. The database only has this key 1 time, yet SingleOrDEfault is failing for there being more than 1 item returned.
 
     
    