score:1
Accepted answer
stringbuilder recentstring = new stringbuilder();
recentstring.append("<ul>");
foreach (blog_post h in recentblogdata)
{
datetime blogdate = datetime.parse(h.blogpublishdate.tostring());
recentstring.append("<li>");
recentstring.append("<div class=\"date\"><span>");
recentstring.append(blogdate.tostring("%d"));
recentstring.append("</span>");
recentstring.append(blogdate.tostring("mmm").tolower());
recentstring.append("</div>");
recentstring.append("<strong><a href=\"");
recentstring.append(s.geturl("site") + "/news/" + h.blogpostid + "/" + g.clean(h.blogposttitle).tolower() + "\">" + h.blogposttitle)
recentstring.append("</a></strong>");
recentstring.append("<div class=\"cl\"></div>");
recentstring.append("<p>" + h.blogreadmore + "<br />");
recentstring.append("</p></li>");
}
recentstring.append("</ul>");
score:1
var q =
from h in recentblogdata
let blogdate = datetime.parse(h.blogpublishdate.tostring());
select "<li>" +
"<div class=\"date\"><span>" + blogdate.tostring("%d") + "</span>"
+ blogdate.tostring("mmm").tolower() + "</div>" +
"<strong><a href=\"" + s.geturl("site") + "/news/" + h.blogpostid
+ "/" + g.clean(h.blogposttitle).tolower() + "\">"
+ h.blogposttitle + "</a></strong>" +
"<div class=\"cl\"></div>" +
"<p>" + h.blogreadmore + "<br />" +
"</p>" + "</li>";
var result = "<ul>" + string.concat(q) + "</ul>";
Source: stackoverflow.com
Related Query
- LINQ Getting Distinct Data and looping through to get related data
- Linq Looping through Data
- How to access oracle data using Linq through ADO.net?
- Looping Through LINQ Queries and Appending Results to DataTable
- Quicker way to loop through LINQ data
- How to cast INT32 to INT during a SQL select through a LINQ data context?
- About data transfer one object to array through LINQ
- How to remove selected data that found on another list and take last 6 id through LINQ without foreach loop
- Displaying sequence numbers for the records in the DataTable and data binding is done through LINQ
- Data through Linq - EntityFramework - SQL database connection does not 'refresh'
- How to get Json data through LINQ in WCF?
- Duplicate key error but no entry with same values to be found when inserting data through LINQ
- Linq To SQL: Most Efficient Way of Looping through List of ID's
- LINQ - looping through rows of 2d array
- Looping through a dynamic linq object with joins
- Looping through a Linq Result Set with Multiple Joins
- Using LINQ to iterate through a database and generate a generic XML layout of schema + data
- C# Linq expressions can't loop through data results?
- LINQ Create new Xdocument by looping through existing XML file
- linq looping through tags with the same name
- Looping through Linq query
- Concert tabular data into Objects through LINQ
- Getting related data through navigation in linq
- LINQ version of looping through array and performing multiple types of replacements
- How do I iterate through each column of data in a LINQ to SQL query?
- Linq to Entity Where built by looping over data
- Failed to insert data through LINQ to SQL server
- C# Looping through nested LINQ select statements
- Looping through Xml data to output result
- Edit data of a WCF Data Service through LINQ
More Query from same tag
- Conditional UNION in LINQ (or is there a better way than UNIONs)?
- Why IEnumerable<T> is defined as IEnumerable<out T>, not IEnumerable<T>
- Linq to check if all value from another list exist
- Any way to read a CSV into an array or datatable using linq?
- couldn't get the result by linq
- LINQ query for retrieving items that contain any value from a list?
- Linq to Sql SelectMany
- LINQ Left join on nullable column giving null reference exception
- Linq To SQL - Specified cast is not valid - SingleOrDefault()
- LINQ to SQL bug (or very strange feature) when using IQueryable, foreach, and multiple Where
- LINQ Join and GroupJoin
- Make a LINQ select O(n), selecting just one element
- Splitting an ordered list
- unsigned int mysql in C#
- Adding primary key on datatable
- how to pass a LINQ query to a WCF service
- Is it possible to have one LINQ in one line of code for
- Left outer join null reference error in LINQ
- How to Solve Linq Incorrect Date Query
- JSON.NET: Flattening a JArray to JObjects within Linq Query
- VS2010 linq Goes To shortcut
- How to deal with multiple Enumerable.Zip calls?
- Join between in memory collection and EntityFramework
- Converting linq result set to data table
- EF6 Condition based on sub child
- Unable to cast object of type 'System.Collections.Generic.HashSet`1[libraryWebProject.Major]' to type 'libraryWebProject.Major'
- Using LINQ to update string array
- Expression<Func<PartJoinTable, bool>> predicate=null; throws error in where condition(query.Where(predicate))
- Create an iQueryable which is case insensitive for unit testing linq to entities - NSubstitute
- LINQ select column(s) of table before doing multiple joins