I have to concat 2 linq2sql query and I have an issue since the 2 query doesn’t return the same number of columns, what is weird is after a .ToList() on the queries, they can concat without problem.
The reason is, for some linq2sql reason, I have 2 more column named test and test2 which come from 2 left outer join that linq2sql automatically create, something like “select 1 as test, tablefields”
Is there any good reason for that? how to remove this extra “1 as test” field?
here a few of examples of what it look like: google result for linq 2 sql “select 1 as test”
OK, let’s assuming we have 2 tables:
dbo.Useranddbo.Client. Eachclientmay be connected (or not) touser. Soclientrecords have a nullable foreign key field identifying auser.For the query:
LINQ will produce something similar to:
Since not all
clientrecords have a matchinguserrecord, LINQ is creating a query that ensures there will be a row filled with nulls for every userlessclient. This is done by creating an extra dummy column called[test].So rows which have
[test]column value set to1are really connected touserentity.I suppose this
[test]column is used by LINQ as a flag that means “hey, here is a client with user defined”.If I decide to rewrite this query, I’ll use
userprimary key as the indicator, but it seems for LINQ it is easier to use[test]column.