ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Display records count from Database using Entity Framework in ASP.Net<p>Hi <a class="username" rel="Rezu2215"> Rezu2215</a>,</p> <p>Refer below sample.</p> <p><span style="text-decoration: underline;"><strong>Database</strong></span></p> <p>For this sample I have used of NorthWind database that you can download using the link given below.</p> <p><a href="https://www.aspsnippets.com/Articles/Install-the-Northwind-and-Pubs-Sample-Databases-in-SQL-Server-Express.aspx" target="_blank">Download Northwind Database</a></p> <p><span style="text-decoration: underline;"><strong>HTML</strong></span></p> <pre class="brush: html">&lt;asp:Label id=&#34;lblCount&#34; runat=&#34;server&#34; /&gt; &lt;br /&gt; &lt;asp:Label id=&#34;lblCountryCountUSA&#34; runat=&#34;server&#34; /&gt; &lt;br /&gt; &lt;asp:Label id=&#34;lblCountryCountUK&#34; runat=&#34;server&#34; /&gt;</pre> <p><span style="text-decoration: underline;"><strong>Namespaces</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">using NorthwindModel;</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Imports NorthwindModel</pre> <p><span style="text-decoration: underline;"><strong>Code</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">protected void Page_Load(object sender, EventArgs e) { NorthwindEntities entity = new NorthwindEntities(); var result = (from emp in entity.Employees select emp); var countryCountUSA = (from emp in entity.Employees select emp).Where(x =&gt; x.Country == &#34;USA&#34;); var countryCountUK = (from emp in entity.Employees select emp).Where(x =&gt; x.Country == &#34;UK&#34;); lblCount.Text = &#34;Total Number of Records : &#34; + result.Count().ToString(); lblCountryCountUSA.Text = &#34;USA Record Count is : &#34; + countryCountUSA.Count().ToString(); lblCountryCountUK.Text = &#34;UK Record Count is :&#34; + countryCountUK.Count().ToString(); }</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load Dim entity As NorthwindEntities = New NorthwindEntities() Dim result = (From emp In entity.Employees Select emp) Dim countryCountUSA = (From emp In entity.Employees Select emp).Where(Function(x) x.Country = &#34;USA&#34;) Dim countryCountUK = (From emp In entity.Employees Select emp).Where(Function(x) x.Country = &#34;UK&#34;) lblCount.Text = &#34;Total Number of Records : &#34; &amp; result.Count().ToString() lblCountryCountUSA.Text = &#34;USA Record Count is : &#34; &amp; countryCountUSA.Count().ToString() lblCountryCountUK.Text = &#34;UK Record Count is :&#34; &amp; countryCountUK.Count().ToString() End Sub</pre> <p><span style="text-decoration: underline;"><strong>Output</strong></span></p> <div><span id="lblCount">Total Number of Records : 9</span></div> <div><span id="lblCountryCountUSA">USA Record Count is : 5</span></div> <div><span id="lblCountryCountUK">UK Record Count is :4</span></div>https://www.aspforums.net:443/Threads/199586/Display-records-count-from-Database-using-Entity-Framework-in-ASPNet/https://www.aspforums.net:443/Threads/199586/Display-records-count-from-Database-using-Entity-Framework-in-ASPNet/Wed, 12 Jun 2019 04:39:16 GMT