Announcement

Showing posts with label LINQ. Show all posts
Showing posts with label LINQ. Show all posts

Transforming XML to HTML using LINQ to XML



Converting XML to HTML using C#
XML to HTML
In the post Create xml file in C# .net, we got to know about how to create XML file in C#. As mentioned in the previous post, XML helps creating our own tags and it focuses on what data is rather than how data looks. But... many a times it is important how data looks, to get the better look and feel. Thus need arises to convert the XML data into HTML format.

In this post we will convert XML file that we created previously into HTML format.

How to compare only month part of DateTime field using LINQ

Getting all values of a particular column by comparing Month part of DateTime field in SQL using Linq.

Fetch the month of date time field using the Value property in Linq. Then get the Month of it as: f.ForDate.Value.Month

e.g., the following query will get all start time as an array of String where the Month of ForDate field in Table FPCTimeMaster matches the Month of DateTime field timeMasterDate.

string[] startTimes = context.FPCTimeMasters.Where(f =>f.ForDate.Value.Month == timeMasterDate.Month && f.ChannelId == channelID ).Select(s => s.StartTime).ToArray();