How to write Sql In Operator in Linq

As we always go through in operator to pass some parameter to in like

select id,name,address from tbl_address where name in (‘anand’,’kumar’) . To implements this query in linq we need to create a list with the type of sql column datatype. If Name is Varchar then go with List ,if id int the go with list


its very similar to sql statements but in WHERE class of linq we need to pass listObj.Contains()

Please try the same like

in the above example I am using Name that is type of varchar so I create List objList . For searching data I use where listobj.Contains(i.Name)

happy coding

Anand Kumar
@anandkumarv

Anand Kumar

Sr.Tech Lead at CsharpMagic
I am founder of csharpmagic.com and by profession Sr.Tech Lead. I like to explore New Technologies, New Business idea and many more
Anand Kumar
@anandkumarv

Latest posts by Anand Kumar (see all)

Anand Kumar

I am founder of csharpmagic.com and by profession Sr.Tech Lead. I like to explore New Technologies, New Business idea and many more

Leave a Reply

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