top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to use SQL like Operator in LINQ and C#?

0 votes
371 views
How to use SQL like Operator in LINQ and C#?
posted May 12, 2016 by Sathyasree

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes
using System;

using System.Collections.Generic;

using System.Data;

using System.Linq;

namespace AbundantCode

{

internal class Program

{

//How to use SQL Like Operator in LINQ and C# ?

private static void Main(string[] args)

{

List<CodeSnippet> snippets = new List<CodeSnippet>()

{

new CodeSnippet { Code = "1" , Name = "Abundantcode1"},

new CodeSnippet { Code = "2" , Name = "Abundantcode2"},

new CodeSnippet { Code = "3" , Name = "Abundantcode1"},

new CodeSnippet { Code = "4" , Name = "Abundantcode2"},

new CodeSnippet { Code = "5" , Name = "Abundantcode4"}

};

var data = (from m in snippets

where m.Name.Contains("code2")

select m);

foreach (var item in data)

Console.WriteLine(item.Name);

Console.ReadLine();

}

}

public class CodeSnippet

{

public string Name { get; set; }

public string Code { get; set; }

}

}
answer May 12, 2016 by Shivaranjini
...