0
  • InterSystems IRIS
  • SQL Server
  • Windows
  • Database
  • DB2
  • C#
  • COBOL
  • SQLite
  • C
  • ASP.NET
  • Android
  • C++
  • MySQL
  • Visual Studio
  • Deals
  • News
  • InterSystems IRIS
  • SQL Server
  • Windows
  • Database
  • DB2
  • C#
  • COBOL
  • SQLite
  • C
  • ASP.NET
  • Android
  • C++
  • MySQL
  • Visual Studio
  • Deals
  • News
Abundant Code
Abundant Code

Abundant Code

  • Home
  • Daily Reads
  • C#
  • Python
  • SQL Server
0

Abundant Code

  • Home
  • Daily Reads
  • C#
  • Python
  • SQL Server
This Week Trend

How to return Http Status Code from ASP.NET Web API Controller ?

1 Min Read

How to Allow only numeric input in a Textbox in WPF ?

1 Min Read

How to open display settings from command line in Windows 10 ?

1 Min Read

How to Quickly Delete All Rows in a Table in Entity Framework?

1 Min Read
0
Abundant Code > C# > How to use SQL like Operator in LINQ and C#?
C#

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

Posted by AbundantCode

In a SQL Query, one might use the Like Query which can be used along with the % operator to search of contains within the data. How to use SQL like Operator in LINQ and C#? This article will show it with a sample code snippet.

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

Below is a sample source code demonstrating the usage of Contains extension method which returns the same results like the SQL “Like” operator.

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; }

}

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

Share this:

  • Post

Like this:

Like Loading...
Tags: C# How to LINQ operator SQL like
Share on
Share on Facebook Share on Twitter Share on WhatsApp Share on WhatsApp Share on Telegram
AbundantCode September 17, 2024
Previous Article InterSystems Cache & Ensemble Error 6093 – Unexpected end of message found. Invalid MIME format.
Next Article SQL Server Error Code – 11728 the sequence object ‘%.*ls’ has reached

Leave a Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • AbundantCode Daily Read – June 05, 2025
  • AbundantCode Daily Read – March 29, 2025
  • AbundantCode Daily Read – March 03, 2025
  • AbundantCode Daily Read – February 06, 2025
  • AbundantCode Daily Read – January 08, 2025
  • AbundantCode Daily Read – January 05, 2025
  • AbundantCode Daily Read – November 9, 2024
  • InterSystems Cache & Ensemble Error 2042 – Failed to find our mirror name (%1) in the mirror configurat
  • Apache Derby DB Error Code XSLB4 – Cannot find truncationLWM .
  • IBM FlashSystem V9000 Error – 1268 – 045119

Top Posts & Pages

  • How to fix the Oracle error PGU-00309: cannot close spool file string?
  • SAP HANA SQL Error Code 4882 - ERR_GEM_LOCAL_NAME_ALREADY_EXISTS
  • How to fix the Oracle error JMS-00190: Queue {0} not found?
  • InterSystems IRIS TSQL Code 21129 Terminating immediate updating or queued
  • Hydra Error 110 ISAM error: end or beginning of the file.
  • InterSystems IRIS Productios Error Code - ErrNoSQLStatement
  • Windows System Error Code 8409 - ERROR_DS_DATABASE_ERROR (0x20D9)]
  • Windows System Error Code 15107 - ERROR_MUI_INTLSETTINGS_UILANG_NOT_INSTALLED (0x3B03)]
  • Hydra Error 184 Message number -184 not found.
  • How to fix the Oracle error ORA-31418: source schema string does not exist?

Blog Categories

  • .NET3,058
  • Android3
  • Angular4
  • Apache Derby913
  • API385
  • ASP.NET16
  • Assembly Language19
  • Azure40
  • Blogging4
  • C66
  • C#1,966
  • C++17
  • COBOL287
  • Daily Reads7
  • Database1,072
  • DB2802
  • Delphi67
  • Elastic Search3
  • Entity Framework3
  • Excel7
  • F#26
  • Google37
  • Guide1
  • How to3
  • HTML2
  • Hydra368
  • IBM197
  • IBM FlashSystem736
  • IBM Sterling668
  • IBM TS4500 Tape Library348
  • Ingress35
  • Interbase347
  • InterSystems Cache & Ensemble2,764
  • InterSystems IRIS7,439
  • Interview Questions3
  • Java69
  • JavaScript23
  • jQuery2
  • MariaDB882
  • Microsoft Office2
  • MySQL2
  • NETWORK1
  • News17
  • Oracle26,825
  • PHP4
  • popular1
  • PowerShell1
  • Python50
  • Raima RDM1,052
  • Ruby1
  • SharePoint1
  • SQL Server14,061
  • SQL Server7
  • SQLite105
  • Uncategorized2
  • Unix1
  • VB.NET8
  • Visual Studio11
  • WebAPI4
  • What is?4
  • Windows3,230
  • Windows Azure3
  • Windows Forms8
  • WordPress1
  • XAML12

Tags

.NET Errors App C# C# Errors C# programs COBOL Error Messages csharp database Database Error Messages DB2 Error Messages Delphi Errors Erply API F# Google Play guide How to IBM Application Discovery and Delivery Intelligence IBM InfoSphere Information Server IBM QRadar IBM Workload Automation InterSystems IRIS Errors Java Javascript Lab programs LINQ List MariaDB Errors MS SQL Server Error Codes Oracle Errors python tutorials SQL Server tips tricks TroubleShoot SQLite Errors tutorial tutorials visual studio 2015 Windows Windows 10 Windows Errors Windows Phone Windows Phone 8 Windows System Errors wp8 XAML

You Might Also Enjoy

C# Compiler Error – CS8780 a variable may not be declared within a

Posted by AbundantCode AbundantCode 0 Min Read

Json.NET & VB.NET – Installing Json.NET for VB.NET projects in Visual Studio 2015

Posted by AbundantCode AbundantCode 3 Min Read

C# – How to Call the base constructor ?

Posted by AbundantCode AbundantCode 0 Min Read

©2021 Abundantcode

Login Register

Login

Lost Password
Oops! Sorry, registration is disabled.
%d