Click here to Skip to main content
15,905,612 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I was using for chek unique through c# coding with the help of sqlcommand class write :
select count(*) as v_count from  dbo.BookTopic where TopicId <>1 and Topic='abc'


that is working fine...

But i want to write this coding in linq ...please help me...




Thank's in Advance.
Posted
Updated 24-May-11 13:43pm
v3

I am assuming that you have a collection class called BookTopic. Then here is what the SQL query will look like in LINQ.

C#
int count = (from bt in new BookTopic()
               where !bt.TopicId.Equals(1) && bt.Topic.Equals("abc")
               select bt).ToList().Count;


I hope this helps you well.
 
Share this answer
 
v2
Comments
NandaKumer 25-May-11 14:28pm    
Good
Wonde Tadesse 6-Dec-11 10:51am    
Thanks
u can use conditional count in LINQ
see this link
http://msdn.microsoft.com/en-us/vcsharp/aa336747#countConditional[^]
 
Share this answer
 
Comments
Niranjankr 24-May-11 1:40am    
try to understand my Question ...before insert in database i want to check is Data Unique or not through Linq....
Ashishmau 24-May-11 1:53am    
so what, First of all, take ur column data from database in collection list and then u can check for unique values using linq as provided in above link.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900