Note that there are some explanatory texts on larger screens.

plurals
  1. POGet all data from both table using Linq to sql
    primarykey
    data
    text
    <p>I have two tables BIReport and tblFormat. I am using linq to sql in my project.</p> <p>I want to get data using linq to sql which will be same as the following query.</p> <pre><code>Select A.*,B.* from Report A inner join tblFormat B on A.ReportId = B.SettingId. </code></pre> <p>Using above query it will get all data from both table. So How to receive all data from both tables using linq to sql.</p> <p>Updated :</p> <pre><code> &lt;form id="form1" runat="server"&gt; &lt;div&gt; &lt;asp:GridView ID="grddata" runat="server"&gt;&lt;/asp:GridView&gt; &lt;/div&gt; &lt;/form&gt; </code></pre> <p><strong>Update2:</strong></p> <p>My query:</p> <pre><code> var QInnerJoin1 = (from p in objtest.Reports join p2 in objtest.tblFormats on p.ReportId equals p2.SettingID where p2 != null select new { p, p2 }).ToList(); grddata.DataSource = QInnerJoin1; grddata.DataBind(); </code></pre> <p>My Error and Data![enter image description here][2]</p> <p>Solutions:</p> <p>I have created a class for property which I need to bind to Grid view:</p> <pre><code>public class TestLinqToSql { public int ReportId { get; set; } public string ReportName { get; set; } public string FormatName { get; set; } } </code></pre> <p>Then I have updated my linq to sql as per below:</p> <pre><code> List&lt;TestLinqToSql&gt; objList = (from p in objtest.Reports join p2 in objtest.tblFormats on p.ReportId equals p2.SettingID where p2 != null select new TestLinqToSql() { ReportId = p.ReportId, ReportName = p.ReportName, FormatName = p2.FormatName }).ToList(); grddata.DataSource = objList1; grddata.DataBind(); </code></pre> <p>Its works for me. Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload