Hi
I want if there is value in Status then it should return only those records else it should return all records.
C#
List Result = (from t in context.View_Details
where t.FromDate.Value.Date >= frDate.Date && t.FromDate.Value.Date <= toDate.Date
&& (t.Status != "" ? t.Status == TStatus.ToString() : 1 == 1)
select t).ToList();
return Result;Thanks

Sachin SinghRank #66 · 26.2K reputationPosted Oct 9, 2022, 4:00 AM EDT
test this
List Result = ( from t in context.View_Details where t.FromDate.Value.Date >= frDate.Date && t.FromDate.Value.Date <= toDate.Date && (string.IsNullOrEmpty(t.Status)||t.Status == TStatus.ToString()) select t ).ToList(); return Result;Jignesh KumarRank #91 · 22.9K reputationPosted Oct 9, 2022, 2:15 AM EDT
Hi Ramco,
Please use below query which will help you out,
List result = new List(); var q = (from t in context.View_Detailswhere t.FromDate.Value.Date >= frDate.Date && t.FromDate.Value.Date x.Status == TStatus.ToString()).ToList(); } else { result = q.ToList();; }return result;