Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

How to return a list to view after foreach in c#

// Replace DocInfo with the correct type name of the db.docinfo model
var res = new List<DocInfo>();

foreach (var i in find)
{
    var entities = db.docinfo.Where(z => z.RequestID == i.BookingID).ToList();
    res.AddRange(entities);
}

return View(res);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #How #return #list #view #foreach
ADD COMMENT
Topic
Name
9+7 =