Sanjay Sharma

Sanjay Sharma

  • 1.3k
  • 413
  • 27.7k

string.Contains

Jun 20 2018 7:16 AM
Hi,
I have following data
 
 
 
I required function rows having functionId = 3 and not 13.
in c# 
 
=================================
 int FunctionId = 3;
var DFKeywords = entity.DefaultKeywords.Where(DF => DF.FunctionId.Contains(FunctionId.ToString())).ToList();
 
will include 3 as well as 13 too any quick solution to this?
 
Although I achived this as 
================================= 
int FunctionId = 3;
 
List<DefaultKeyword> DFKeywords = new List<DefaultKeyword>();
foreach (var item in entity.DefaultKeywords.Where(df=> df.FunctionId != null) .ToList())
{
var functionIds = item.FunctionId.Split(',');
if (functionIds.Contains(FunctionId.ToString()))
{
DFKeywords.Add(item);
}
}
 
 

Answers (2)