ASPForums.Net RSS Feed additions to the content that appears on ASPForums.Net(c) 2019 All rights reserved.Write JOIN Queries using LINQ to SQL and Entity Framework in C# and VB.Net<p>Hello Everybody,</p> <p>I am having problems in joining tables using entity framework&nbsp;&nbsp;6.1.3</p> <p>help me by giving example with it is description and it syntax&nbsp;</p> <p>Suppose I want to Write the following queires using entityframework</p> <p><strong>INNER JOIN</strong></p> <p>SELECT Orders.OrderID, Customers.CustomerName<br />FROM Orders<br />INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID;</p> <p><strong>LEFT JOIN</strong></p> <p>SELECT Customers.CustomerName, Orders.OrderID<br />FROM Customers<br />LEFT JOIN Orders ON Customers.CustomerID = Orders.CustomerID<br />ORDER BY Customers.CustomerName;</p> <p><strong>RIGHT JOIN</strong></p> <p>SELECT Orders.OrderID, Employees.LastName, Employees.FirstName<br />FROM Orders<br />RIGHT JOIN Employees ON Orders.EmployeeID = Employees.EmployeeID<br />ORDER BY Orders.OrderID;</p> <p><strong>FULL OUTER JOIN</strong></p> <p>SELECT Customers.CustomerName, Orders.OrderID<br />FROM Customers<br />FULL OUTER JOIN Orders ON Customers.CustomerID=Orders.CustomerID<br />ORDER BY Customers.CustomerName;</p> <p><strong>SELF JOIN</strong></p> <p>SELECT A.CustomerName AS CustomerName1, B.CustomerName AS CustomerName2, A.City<br />FROM Customers A, Customers B<br />WHERE A.CustomerID &lt;&gt; B.CustomerID<br />AND A.City = B.City&nbsp;<br />ORDER BY A.City;</p> <p>thanks&nbsp;</p>, 15 Jan 2018 00:37:39 GMTWhich is best to use in ASP.Net MVC ADO.Net or Entity Framework<p>Hi...</p> <p>i want fatch data from ERP database ,its having all lots stored procedure ,i want fatch data in MVC Application which database connectitvity&nbsp; is best ADO.NET OR Entity framework ???.</p> <p>&nbsp;</p> <p>Please provide your commands...</p> <p>&nbsp;</p> <p>Thanks &amp; Regards,</p> <p>VENKAT</p> <p>&nbsp;</p> <p>&nbsp;</p>, 17 Aug 2018 09:13:45 GMTUsing Group By clause with Entity Framework in C# .Net<p>i have a scenario where i have to display the state name and number of cities in that state in autocompletet text how to do that</p> <p>&nbsp;</p> <pre class="brush: csharp">[HttpPost] public JsonResult find(string Text) { var suggestedUsers = (from x in lw.RWW_CountriesMaster where x.Country.StartsWith(Text) select new { country = x.Country, capital = x.Capital }).Distinct(); var count = (from x in lw.RWW_CountriesMaster where x.Country.StartsWith(Text) select new { country = x.Country, capital = x.Capital }).Count(); var result = suggestedUsers.Take(5).ToList(); //return result; return Json(result, JsonRequestBehavior.AllowGet); }</pre> <p>&nbsp;</p>, 17 Sep 2014 02:36:28 GMTUse Stored Procedure with Entity Framework in ASP.Net<p>hi</p> <p>how witre procuder or function in Entity framwork.</p> <p>please attend&nbsp; me i want create or write in Designing&nbsp; ef</p> <p>i dont want add from db sql</p> <p>&nbsp;</p> <p>&nbsp;</p>, 13 Mar 2013 00:34:27 GMTUsing Stored Procedure with Entity Framework in Linq query in ASP.Net<p>hi,</p> <p>I am trying to pass parameter to sp in an MVC controller.</p> <p>The stored procedure has a parameter that return a table from a string like 's1,s2,s3' (i have a Split Function in database).</p> <p>In Sql works fine but in my project i get model with no entities</p> <p>when i select the checkboxes that represent the multifilter i have no result</p> <p>I create a comma separated string when user checks the checkboxes that represent the product lines and then i use that string as parameter in stored procedure.</p> <p>i have a sp that works like</p> <pre class="brush: sql">select * from tab where produtLine In (select value from dbo.Split(COALESCE(@Linea,&#34;xxxx&#34;, &#34;,&#34;)...etc</pre> <p>the code in c# works but when i try to pass as Line Line1,Line2..etc I recive no result</p> <p>the code</p> <pre class="brush: csharp"> public ActionResult Index(String cliente, int ? anno, String [] linea, String tipoDati ) { String Codage = &#34;000&#34;; tipoDati = &#34;Ordini&#34;; string lineeSelezionate = null; cliente = cliente == &#34;cliente&#34; ? null : cliente; if (linea != null) { foreach (var item in linea) { lineeSelezionate += item + &#34;,&#34;; } lineeSelezionate = &#34;&#39;&#34; + lineeSelezionate.Substring(0, lineeSelezionate.Length - 1) + &#34;&#39;&#34;; } IEnumerable&lt;OrdineMeseLineaView&gt; model; if (string.IsNullOrEmpty(cliente) &amp;&amp; anno == null &amp;&amp; linea == null) { model = new List&lt;OrdineMeseLineaView&gt; { new OrdineMeseLineaView { Linea = &#34;&#34;, Gen = 0, Feb = 0, Mar = 0, Apr = 0, Mag = 0, Giu = 0, Lug = 0, Ago = 0, Set = 0, Ott = 0, Nov = 0, Dic = 0,Tot=0} }; } else { model = db.Database. SqlQuery&lt;OrdineMeseLineaView&gt;(&#34;dbo.PivotOrdiniMeseLineaSp @p0, @p1,@p2, @p3&#34;, Codage, (object)cliente ?? DBNull.Value, (object)anno ?? DBNull.Value, (object)lineeSelezionate ?? DBNull.Value).ToList(); } return View(model); }</pre>, 13 Nov 2017 06:44:51 GMTUsing Stored Procedure with Entity Framework in ASP.Net MVC<p>How to use a stored procedure in MVC project with Entity framework</p> <p>&nbsp;</p> <p>Thanks</p> <p>R</p>, 27 Nov 2018 05:45:39 GMTUsing reflection to loop through related tables in entity object in ASP.Net<p>Hi there&nbsp;</p> <p>&nbsp;</p> <p>I need some help how do i&nbsp;using reflection to loop through related tables in entity object. so that i can find if and entitiy object is been used in any of the other tables</p>, 24 Jun 2016 02:25:03 GMTUsing Lambda expression instead of For Each Loop in ASP.Net<p>I have used for each loop and counter, I got code review comment like "please use a lamba expression here, to isolate an occurrence, as opposed to iterating over all and then doing something in response to all found "</p> <p>Please help how to use lamda expresion here. Thanks.</p> <pre class="brush: vb">Private Function DiamondScoreCheckForOdType(ByVal currentPolicyLob As String, ByVal predominantState As String, ByVal policyEffectiveDate As Date) As Boolean Dim listOfLobForDiamondScoreRule As New HashSet(Of String) From {{getLineOfBusiness(Lob.LineOfBusiness.Auto)}, {getLineOfBusiness(AutoNonDealer)}, {getLineOfBusiness(Lob.LineOfBusiness.Garage)}, {getLineOfBusiness(EmploymentPracticesLiability_EP)}, {getLineOfBusiness(GeneralLiability)}, {getLineOfBusiness(InlandMarine)}, {getLineOfBusiness(PesticideHerbicide)}, {getLineOfBusiness([Property])}, {getLineOfBusiness(Umbrella)}} Dim lobList As New List(Of String) Dim eligibleLobCheckCounter As Integer = 0 lobList = currentPolicyLob.Split(ASTERISK).ToList() For Each currentLob In lobList listOfLobForDiamondScoreRule.Contains(currentLob) If (listOfLobForDiamondScoreRule.Contains(currentLob)) Then eligibleLobCheckCounter = eligibleLobCheckCounter + 1 End If Next If (eligibleLobCheckCounter &gt; 0) Then Dim isStateAndEffDateEligible As Boolean = (New LobCO.Shared.COShared).IsStateRuleApplicable(getLineOfBusiness(Lob.LineOfBusiness.Common), predominantState, policyEffectiveDate, DiamondScoreRuleCheckForOdType) Return isStateAndEffDateEligible End If Return False End Function</pre> <p>&nbsp;</p>, 07 Sep 2018 01:52:46 GMTSum of DataTable columns total using Lambda Expression in Entity FrameWork in ASP.Net<pre><font color="red"> decimal total = dt.AsEnumerable().Sum(row =&gt; row.Field&lt;decimal&gt;("TotalAmount"));<br /><br /><br /><br />when i try to add the total amount from grid view row then i'm faicing above error sir</font></pre>, 19 Dec 2016 05:15:01 GMTSum of Column using Linq Lambda Expression in ASP.Net<p>how to use &nbsp;this Query in linq Lamda Expression&nbsp;</p> <pre class="brush: sql">Select&nbsp; sum(AmountPaid) as TotalAmountPaid from StudentLedger where FeeTypeID in&nbsp;(1,2) and StudentID =639</pre> <p>&nbsp;</p>, 18 May 2018 01:12:37 GMTUse Output Parameter with Entity Framework (Edmx) in C# .Net<p>I have develop a function to add textbox value into data base my function work perfectly .now I am using that table primary key into another table where it declare as a foreign key now i required to return my Id as a output parameter in table1 &nbsp;means( set scope identity) &nbsp;&nbsp;&nbsp;so that I used this Id into another table as a foreign key please help me how I used this scope identity into a web method</p> <pre class="brush: js">function Insertdata() { var name = $(&#39;#txtfname&#39;).val(); $.ajax({ type: &#39;POST&#39;, url: &#34;Insert.aspx/DataInsertion&#34;, contentType: &#34;application/json; charset=utf-8&#34;, data: &#39;{name:&#34;&#39; + name + &#39;&#34;, Id:&#34;&#39; + output + &#39;&#34;}&#39;, async: false, success: function (response) { alert(&#34; Saving the Data.!&#34;); }, error: function () { alert(&#34;Some Error occured While Saving the Data.!&#34;); } }); }; </pre> <p>&nbsp;</p> <pre class="brush: csharp">Web method [WebMethod] public static string DataInsertion(string name Id output) { using (var db = new MyEntities())///////this is edmx name { db.Insertion( Name=name, Id=Output ); } return &#34; Data Successfully Saved&#34;; } </pre> <p>I read a lot of article but I have no idea to use it.</p> <p>Please help me&nbsp;</p>, 07 Aug 2015 09:26:31 GMTUpdate Entity Framework Objects using HashTable in ASP.Net<p>I am&nbsp;updating data&nbsp;EF table item&nbsp;by hashtable dynamically but when I do the save changes, my data is not updating in the DB table.&nbsp;&nbsp;</p> <pre class="brush: csharp">UserMaster EntityObj = context.UserMasters.FirstOrDefault(user =&gt; user.DataID == DataID); Type description = typeof(UserMaster); foreach (string htKey in ht.Keys) { PropertyInfo property = description.GetProperty(htKey); object htValue = ht[htKey]; object result = AppHelper.ConvertValueType(htValue, property.PropertyType.Name); property.SetValue(EntityObj, result); } context.SaveChanges();</pre> <p>Here ht is hastable. What is wrong with this code or is there anyway to dynamically bind data to the db model object and update data in database?</p> <pre class="brush: csharp">Hashtable ht = new Hashtable(); ht.Add( &#34;username&#34;, &#34;Abhi&#34; ); ht.Add( &#34;Role&#34;, &#34;Admin&#34; ); ht.Add( &#34;FirstName&#34;, &#34;Abhi&#34; ); ht.Add( &#34;email&#34;, &#34;; );</pre> <p>&nbsp;</p>, 09 Jul 2019 04:03:37 GMTUpdate Database using Migrations with Entity Framework in ASP.Net MVC<p>I wanted to update the database using EF migrations.</p> <p>I have a model class: </p> <pre class="brush: csharp">namespace Movies_Management_System.Models { public class Movie { public int ID { get; set; } [StringLength(60, MinimumLength = 3)] public string Title { get; set; } public DateTime ReleaseDate { get; set; } [RegularExpression(@&#34;^[A-Z]+[a-zA-Z&#39;\s]*$&#34;)] [Required] [StringLength(30)] public string Genre { get; set; } [Range(1, 100)] [DataType(DataType.Currency)] public decimal Price { get; set; } public string Rating { get; set; } } public class MovieDBContext : DbContext { public DbSet&lt;Movie&gt; Movies { get; set; } } }</pre> <p>I have added Rating(extra field) in the class.</p> <p>i referred this link to update the database but its not working for me.</p> <p>Can anyone enlighten me on this?</p> <p>Controller Class:</p> <pre class="brush: csharp">namespace Movies_Management_System.Controllers { public class MoviesController : Controller { private ApplicationDbContext db = new ApplicationDbContext(); public ActionResult Index(string movieGenre, string searchString) { var GenreLst = new List&lt;string&gt;(); var GenreQry = from d in db.Movies orderby d.Genre select d.Genre; GenreLst.AddRange(GenreQry.Distinct()); ViewBag.movieGenre = new SelectList(GenreLst); var movies = from m in db.Movies select m; if (!String.IsNullOrEmpty(searchString)) { movies = movies.Where(s =&gt; s.Title.Contains(searchString)); } if (!string.IsNullOrEmpty(movieGenre)) { movies = movies.Where(x =&gt; x.Genre == movieGenre); } return View(movies); } public ActionResult Details(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } Movie movie = db.Movies.Find(id); if (movie == null) { return HttpNotFound(); } return View(movie); } public ActionResult Create() { return View(); } [HttpPost] [ValidateAntiForgeryToken] public ActionResult Create([Bind(Include = &#34;ID,Title,ReleaseDate,Genre,Price,Rating&#34;)] Movie movie) { if (ModelState.IsValid) { db.Movies.Add(movie); db.SaveChanges(); return RedirectToAction(&#34;Index&#34;); } return View(movie); } public ActionResult Edit(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } Movie movie = db.Movies.Find(id); if (movie == null) { return HttpNotFound(); } return View(movie); } [HttpPost] [ValidateAntiForgeryToken] public ActionResult Edit([Bind(Include = &#34;ID,Title,ReleaseDate,Genre,Price,rating&#34;)] Movie movie) { if (ModelState.IsValid) { db.Entry(movie).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction(&#34;Index&#34;); } return View(movie); } public ActionResult Delete(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } Movie movie = db.Movies.Find(id); if (movie == null) { return HttpNotFound(); } return View(movie); } [HttpPost, ActionName(&#34;Delete&#34;)] [ValidateAntiForgeryToken] public ActionResult DeleteConfirmed(int id) { Movie movie = db.Movies.Find(id); db.Movies.Remove(movie); db.SaveChanges(); return RedirectToAction(&#34;Index&#34;); } protected override void Dispose(bool disposing) { if (disposing) { db.Dispose(); } base.Dispose(disposing); } } } </pre> <p>&nbsp;</p> <p>&nbsp;</p>, 28 May 2019 00:07:35 GMTUnable to add Namespace using Entity Framework in ASP.Net<p>I'm follow your code(<a href="">code link</a>) from here. but I don't understand where I use AddToCustomers Method and I'm unable to Add NameSpace "TestModelNs".<br />Here is my aspx file(<a href="">files link</a>)</p>, 03 Dec 2017 01:05:54 GMTSystem.Data.SqlClient.SqlException: Invalid object name 'Phase1'<p>Hi....,</p> <p>I got an error of&nbsp;System.Data.SqlClient.SqlException: Invalid object name 'Phase1'like this but in my code there is no Phase1..what should i do..plz help me...</p>, 16 Sep 2014 10:04:10 GMTSQLite Error: FOREIGN KEY constraint failed in Entity Framework<p>I try to implement httpdelete but i get FK error</p> <p>If i delete OrderItems and then Orders in sqlite all works great</p> <p>With that configuration I get:</p> <div class="titleerror">SqliteException: SQLite Error 19: 'FOREIGN KEY constraint failed'.</div> <p class="location">Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(int rc, sqlite3 db)</p> <ul> <li> <h2 class="stackerror">SqliteException: SQLite Error 19: 'FOREIGN KEY constraint failed'.</h2> <ul> <li id="frame1" class="frame"> <h3>Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(int rc, sqlite3 db)</h3> </li> <li id="frame2" class="frame"> <h3>Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior)</h3> </li> <li id="frame3" class="frame"> <h3>Microsoft.Data.Sqlite.SqliteCommand.ExecuteReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)</h3> </li> <li id="frame4" class="frame"> <h3>Microsoft.Data.Sqlite.SqliteCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)</h3> </li> <li id="frame5" class="frame"> <h3>Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteAsync(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary&lt;string, object&gt; parameterValues, CancellationToken cancellationToken)</h3> </li> <li id="frame6" class="frame"> <h3>Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)</h3> </li> </ul> </li> </ul> <p>As i understand in fluent Api need to implement configuration</p> <pre class="brush: sql">builder .HasMany(e =&gt; e.OrderItems) .WithOne(e =&gt; e.Order) .HasForeignKey(e =&gt; e.OrderItemId) .OnDelete(DeleteBehavior.Cascade);</pre> <p>I read that the configuration should be placed only in one side right?</p> <p>Not also in OrderItems configuration</p>, 15 Apr 2019 00:18:54 GMTShow GridView specific column value from another Table using Entity Framework in ASP.Net<p>Hello, I have a gridview which is bind to one table And i want to display a column from another table in this gridview using Entity Framework. Both the tables have one of their columns same i.e, ID which is done through Foreign Key. Please help me to display the column from another table in this gridview.</p> <p>Below is my snippet but you can show using your own examples but please refer it as the method shoould be same.</p> <p>Please Reply ASAP.</p> <pre class="brush: csharp">// This is my gridview in which column is to be added: public void BindGrid() { DashboardService getdata = new DashboardService(); var project = getdata.getall(); DashboardGV.DataSource = project; DashboardGV.DataBind(); }</pre> <p>&nbsp;</p> <pre class="brush: csharp">// Its Class.cs: public class InterruptedRuns { public List&lt;Project&gt; getall() { List&lt;Project&gt; file = new List&lt;Project&gt;(); using (VifexDBEntities dbContext = new VifexDBEntities()) { file = dbContext.Projects.Where(x=&gt; x.Status.ToLower() == &#34;error&#34;).ToList(); return file; } } }</pre> <p>&nbsp;</p>, 13 Jun 2019 07:02:39 GMTSelect specific Columns in Entity Framework using Linq query in ASP.Net<p>&nbsp;</p> <pre class="brush: csharp"> var res = tbb.tbl_Enquiry.Where(x =&gt; x.Enq_broker == enq).ToList();</pre> <p>I Want to get not all column some specific column from tbl_Enquiry&nbsp;</p>, 06 Jul 2018 00:13:52 GMTSelect record having age between 18 and 21 using Linq query in Entity Framework<p>i m finding user according to age, but in database i have only date of birth, my dob in database is date type.stores values like&nbsp;1990-08-22,</p> <p>in need to find users from age 18 to age 25</p>, 07 Aug 2018 00:50:14 GMTSelect record from database with Join and where conditions using Linq query in ASP.Net<p>userlist1 showing all user values, but userlist2 not showing value.</p> <p>Can i apply condition where direct to userlist1 how?</p> <pre class="brush: csharp">string dob2 = dobyear2 + &#34;-&#34; + month + &#34;-&#34; + 1; DateTime dob22 = Convert.ToDateTime(dob2); List&lt;User_Detail&gt; userlist = new List&lt;User_Detail&gt;(); // userlist = db.User_Detail.Where(s =&gt; s.Gender == 2 &amp;&amp; s.DOB &lt;= dob21 &amp;&amp; s.DOB &gt;= dob22).ToList(); var userlist1 = (from u in db.User_Detail &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; join st in db.State_Name on u.State equals st.State_Id &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; join h in db.Height_Table on u.Height equals h.Height_Id &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; join e in db.Education_Qualification on u.Education_Qualification equals e.Education_Id &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; join leng in db.Mother_Tongue on u.Mother_Tongue equals leng.Language_id &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; join rlgn in db.Religions on u.Religion equals rlgn.Religion_Id &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; join cast in db.Castes on u.Caste equals cast.Caste_Id &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; join incm in db.AnnuaIncome_Table on u.Annual_Income equals incm.Income_Id &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; select new users_details &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; First_Name = u.First_Name, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Last_Name = u.Last_Name, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Annual_IncomeName = incm.Annual_Income, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Caste1 = cast.Caste1, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Religion_Name = rlgn.Religion_Name, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Language = leng.Language, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EducationName = e.Education, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; StateName = st.State &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }).ToList(); var userlist2 = userlist1.Where(s =&gt; s.Gender == 2 &amp;&amp; s.DOB &lt;= dob21 &amp;&amp; s.DOB &gt;= dob22).ToList(); </pre> <p>&nbsp;</p> <p>&nbsp;</p>, 10 Aug 2018 06:13:54 GMT