Use LINQ Like Oprator for Unicode Languages

11:48 PM

Last day I want to make an LINQ query for selecting some data from data context

I write this code at the first :

1 Dim fn As New DatadcDataContext


2 Dim users = From user In fn.Users _


3 Where user.UserName Like "%مسعود" _


4 Select user





I didn't get any result , that's because of my like operator.

Like operator cant understand Unicode values.

I was angry about that and search the solution for about 3 days and Finlay fined that :)

if you want to use Like operator for LINQ queries you have to do this :

first import this name space :


1 Imports System.Data.Linq.SqlClient



next you must change your LINQ query like this :

1 Dim fn As New DatadcDataContext


2 Dim users = From user In fn.Users _


3 Where SqlMethods.Like(user.UserName, "%مسعود") _


4 Select user


your done !!! enjoy it ^_^

0 comments:

Post a Comment