ASPForums.Net RSS Feed additions to the content that appears on ASPForums.Net(c) 2019 All rights reserved.Common Method or Function return Linq query result in Entity Framework<p>Hi&nbsp;nauna,</p> <p>You can create a method that will return&nbsp;Anonymous types as an object.</p> <p>Check this example. Now please take its reference and correct your code.</p> <p><strong><span style="text-decoration: underline;">Database</span></strong></p> <p>For this example I have used of Northwind database that you can download using the link given below.</p> <p><a href="" target="_blank">Download Northwind Database</a></p> <p><strong><span style="text-decoration: underline;">C#</span></strong></p> <pre class="brush: csharp">protected void Page_Load(object sender, EventArgs e) { var employee = GetEmployees(); } private object GetEmployees() { NorthwindEntities entities = new NorthwindEntities(); var q = from emp in entities.Employees select emp; return q; }</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 employee = GetEmployees() End Sub Private Function GetEmployees() As Object Dim entities As NorthwindEntities = New NorthwindEntities() Dim q = From emp In entities.Employees Select emp Return q End Function</pre> <p>&nbsp;</p>, 11 Jun 2019 05:10:05 GMT