ASP.NET (C#) Question

How to perform linq search with spaces

I have a linq query that takes data from sql table .

In my database values written with the spaces after value like this :

"Johny (and 5 spaces after that) ".
When i try to find "Johny" - (without spaces)query didn't work. But when i search "Johny " (after Johny - 5 spaces, it didnt show there) -it works.

because I can't change something in base , i didn't have permission for this .

How can i make it work without spaces - changing only my query?

My code :

var fidn = (repository.users.Join(repository.usersLG,
post => post.pcod ,
meta => meta.pcod,
(post, meta) => new { Post = post, Meta = meta })
.Where(postAndMeta => postAndMeta.Post.fam_v == "Johny ").ToList())
.Select(x => new Final {
mcod = x.Post.mcod,
pcod = x.Post.pcod,
c_ogrn = x.Post.c_ogrn,
fam_v = x.Post.fam_v,
im_v = x.Post.im_v,
ot_v = x.Post.ot_v,
idGK = x.Meta.idGK });


Asp net web page c# entity framework

Answer

Use Trim: (and also in this case consider changing to the query syntax, IMO more readable when it comes to joins)

var fidn = from post in repository.users 
           join meta in repository.usersLG on post.pcod equals meta.pcod
           where post.fam_v.Trim() == "Johny"
           select new Final {
               mcod = post.mcod,
               pcod = post.pcod, 
               c_ogrn = post.c_ogrn, 
               fam_v = post.fam_v, 
               im_v = post.im_v,
               ot_v = post.ot_v, 
               idGK = meta.idGK
           };

Aslo have a look at C# naming conventions for the names of the properties in the Final object