Reputation: 2060
I have 2 tables in my database and I am writing a query to get data from a specific column. However the LINQ query is returning me an empty result set. I have read multiple posts on SO and online and have tried FirstOrDefault
, First
, Single
, SingleOrDefault
. I have tried checking with Any
but the data set is still empty. I ran the same query on LINQPad and it does return me the correct result.
var connString = from firstTable in _dataContext.Connections
join secondTable in _dataContext.Companies on
firstTable.CompanyID equals secondTable .CompanyID
where secondTable .CompanyName == "Name"
select firstTable .ConnectionString;
What am I doing wrong?
Upvotes: 1
Views: 861
Reputation: 26907
If the query is working in LINQPad your query is correct, you have a problem in your environment. You need to compare the pieces between your environment and LINQPad to see where the disconnect is occurring.
For example, what is _dataContext.Connections.Count()
in both places? Same for _dataContext.Companies.Count()
. Compare different pieces of the query until you find the source of the difference.
Upvotes: 1