Reputation: 259
How can i compare a char value in linq. what i am doing is not working , can anyone suggest me what is wrong with my code. my column is
public char MarketingType { get; set; }
and the size of the column in database is 1
public List<Marketing> MarketVideo { get; set; }
var debs = from s in iMarketingService.GetMarketingContents()
select s;
viewModelMarketing.MarketVideo = debs.Where(t => t.MarketingType =='v').ToList();
above condition is not working and showing me the empty list but when i compare it with other integer type column like below it is working fine for me.
viewModelMarketing.MarketVideo = debs.Where(t => t.AddeddBy == 2).ToList();
any suggestions , or help will be appreciated. thanks
Upvotes: 3
Views: 3210
Reputation: 545
i guess char 1 means a string of length one.
so you can change it to
public string MarketingType { get; set; }
and your condition should be
debs.Where(t => t.MarketingType.Equals("v")).ToList();
Upvotes: 3
Reputation: 1664
Try this :
public List<Marketing> MarketVideo { get; set; }
var debs = from s in iMarketingService.GetMarketingContents()
select s;
viewModelMarketing.MarketVideo = debs.Where(t => t.MarketingType.ToLowerInvariant() =="v").ToList();
Upvotes: 0