0

I am trying to fetch the data from database using database first approach and want to display the data in a list.. I am trying the following code for this

This is my Action method

 public ActionResult transaction()
        {

            var result = from T in db.tbProcTransactions
                         select T.pServiceID;
            return View(result);
        }

and in my view I write this

@model IEnumerable<LinQuery.Models.tbProcTransaction>

@{
    ViewBag.Title = "transaction";
}

<h2>transaction</h2>

@foreach (var serviceID in @Model.pServiceID)
{
    @serviceID;
}

But when I run this code I get this Error

System.Collections.Generic.IEnumerable' does not contain a definition for 'pServiceID' and no extension method 'pServiceID' accepting a first argument of type 'System.Collections.Generic.IEnumerable' could be found (are you missing a using directive or an assembly reference?)

I am unable to resolve this error Please resolve this error experts

2
  • is this possibly blogs.msdn.com/b/webdev/archive/2014/10/16/… ? Commented Oct 18, 2014 at 10:52
  • You are returning an IEnumerable<typeof(pServiceID)>. Simplest solution is to use select T; instead of select T.pServiceID; Commented Oct 18, 2014 at 10:54

3 Answers 3

2

Change your foreach statement to

@foreach (var serviceID in Model)
{
  @serviceID;
}
Sign up to request clarification or add additional context in comments.

Comments

0

In Action select T instead of T. pServiceID

Comments

0

Try this:

@model IEnumerable<LinQuery.Models.tbProcTransaction>

@{
    ViewBag.Title = "transaction";
}

<h2>transaction</h2>

@foreach (var serviceID in Model)
{
    serviceID.pServiceID;
}

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.