Click here to Skip to main content
15,892,199 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi,
My task is to validate the data entered in the form page is present in the database or not using linq query
my data is present in mutiple tables,i am using joins to retrieve data but when am validating using If,the condition is not working
Can anyone please provide me linq query for my task

This is the query i used
C#
var query = (from i in dbContext.User_details
                         join j in dbContext.User_addresses on i.Userid equals j.Userid
                         join k in dbContext.Userworkdetails on j.Userid equals k.Userid
                         join l in dbContext.Useredudetails on k.Userid equals l.Userid

                         where i.Userid >= 1


                         select new { Ft = i.Firstname, Lt = i.Lastname, Ct = j.City, Co = j.Country, Com = k.Company, Col = l.College }).First();


 if (FirstName == query.Ft || LastName == query.Lt || City == query.Ct || Country == query.Co ||
                Company == query.Com)

            { return Json(query, JsonRequestBehavior.AllowGet); }

            else
            {
                var n = new { s = "this is nt correct name" };
                return Json(n, JsonRequestBehavior.AllowGet);
            }
Posted
Updated 16-May-12 21:12pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900