Home > DeveloperSection > Forums > LINQ to SQL execute method on select
Pravesh Singh
Pravesh Singh

Total Post:101

Points:709
Posted on    September-02-2014 12:40 AM

 ASP.Net ASP.Net 
Ratings:


 1 Reply(s)
 881  View(s)
Rate this:

I’m really new to LINQ so I'm trying to figure out how to execute method with lambda expressions.

   public void GetData()

    {

     using (MyClassesDataContext context = new MyClassesDataContext())

                {

                    var problems = (from p in context.Problems select p).Take(10);

                    problems.Select(t => DisplayData(t.Text));

                }

    }

     public void DisplayData(string Text)

            {

            }

I'm getting this error:

The type arguments for method 'System.Linq.Enumerable.Select(System.Collections.Generic.IEnumerable, System.Func)' cannot be inferred from the usage. Try specifying the type arguments explicitly.

at this line:

 problems.Select(t => DisplayData(t.Text));

What am I doing wrong?



Sumit Kesarwani

Total Post:378

Points:2694
Posted on    September-02-2014 12:52 AM

Hi Pravesh, 

I think that if you make the following change to your code, it will work fine:

problems.Select(t => { DisplayData(t.Text); return true; })


Don't want to miss updates? Please click the below button!

Follow MindStick