markrendle / Simple.Data

A light-weight, dynamic data access component for C# 4.0
MIT License
1.33k stars 303 forks source link

Join not working when more than one table has same name with different schema name #343

Open prasannasgm2014 opened 10 years ago

prasannasgm2014 commented 10 years ago

Scenario: when more than one table has same name with different schema name and tried to join two sql tables in Simple.Data i get "Sequence contains more than one element" error.

Here is the example.

The scenario is we need to have two tables with the different schema like below in the DB. In the below example even though you did not use ModelTest.Class1 in the join when you try to use _db.Model.Class1 with _db.Model.Class2 you get "Sequence contains more than one element" error.

1.Model.Class1 2.ModelTest.Class1

                   List<SomeClass> data = _db.Model.Class1.FindAllBy(Id:Id)
            .OuterJoin(_db.Model.Class2).On(Code: _db.Model.Class1.Code)
            .Select(
                 _db.Model.Class1.ID
              ); 

Please clarify if you have any workaround or any fix available for this issue

Timothep commented 10 years ago

Could you please give us the query you fired to get this exception? Thanks!

prasannasgm2014 commented 10 years ago

Pasted the query sample in the original issue description

prasannasgm commented 9 years ago

is this issue fixed by any chance?

jjamsek commented 9 years ago

I am seeing this issue as well. Any table with the same name that exists in more than one schema returns this error. i.e. schema1.DuplicateTableName and schema2.DuplicateTableName exist in the same database. var someTable = db.schema1.DuplicateTableName.All().ToList(); returns "Sequence contains more than one element"