0

I'm trying to learn LINQ. I have

var mydata = from k in db.emp_mains select k.empname.Equals("me");

But after this statement i the auto complete wont complete the table fields name

foreach(var x in mydata)
{
     ---> Autocomplete not working  Console.WriteLine(x.empname);
}

Why is this happening? Kindly advice.

2 Answers 2

2

Your condition need to go into where clause

var mydata = (from   k in db.emp_mains 
              where  k.empname.Equals("me")
              select k
             ).ToList();
Sign up to request clarification or add additional context in comments.

Comments

1

What you want is to filter with the where statement:

var myData = from k in db.emp_mains
where k.empname == "me"
select name

I much prefer the linq syntax like this for simple statements however:

var myDate = dc.emp_mains.where(w => w.empname == "me").Select(s => s.name).ToList();

Either way, you should get a list on names.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.