C# LINQ Search between date

The SQL BETWEEN operator we can use in C# code. Before your query you have to use
System.Globalization.CultureInfo culInfo = new System.Globalization.CultureInfo("en-US");  


Consider the Example:
internal List<ECalendarSetup> GetCalenderInfoOnSelectedDate(ECalendarSetup calendarSetup)
        {
            ieclHrmDataContext = new IECL_HRMDataContext();
            List<ECalendarSetup> calendarSetupsList = new List<ECalendarSetup>();
            var query = from j in ieclHrmDataContext.HR_CALENDAR_INFOs
                        where j.CAL_DAY_DATE >= calendarSetup.FromDate && j.CAL_DAY_DATE <= calendarSetup.ToDate
                        select j;
            foreach (var calendarInfo in query)
            {
                ECalendarSetup eCalendarSetup = new ECalendarSetup();
                eCalendarSetup.Date = (DateTime) calendarInfo.CAL_DAY_DATE;
                eCalendarSetup.DayStatus = calendarInfo.CAL_DAY_STATUS;
                eCalendarSetup.StartTime = calendarInfo.CAL_START_TIME.ToString();
                eCalendarSetup.EndTime = calendarInfo.CAL_END_TIME.ToString();
                eCalendarSetup.Remarks = calendarInfo.CAL_REMARKS;
                calendarSetupsList.Add(eCalendarSetup);
            }  
            return calendarSetupsList;
        }






Enjoy....

Popular posts from this blog

WPF Crystal Report Viewer Using SAP

mvc razor textboxfor change event change another textboxfor value

ASP.NET MVC razor SAP Crystal report