C# LINQ – Get all data from both table using Linq to sql – Stack Overflow


How to show both table columns from LINQ- 

UPDATE

Actually, looking at your requirements vs. the code you\’ve got then would something like the following not work?

 var innerJoinQuery =  (from A in Reports  join B in ChartSetting on A.ReportId equals B.ReportId  select new { A, B }).ToList();

That is syntactically the same as

Select A.*,B.* from Reports A inner join ChartSetting B on A.ReportId = B.ReportId

A lot of the code you\’ve got in your new query seems to be a bit obsolete – including the creating of result.

Update 2

The list of items you posted has the ChartSetting value to be NULL, so if you really can\’t change the database then try the following:

var innerJoinQuery =  (from A in Reports   join B in ChartSetting on A.ReportId equals B.ReportId   where B != null  select new { A, B }).ToList();

How to Access the columns ? 

innerJoinQuery.A.ColumnName

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s