Himberjack
Himberjack

Reputation: 5792

Facebook friends with LINQ

I am building a linq-to-sql web application and I've encountered a problem. I am trying to use the user's friends list fetched in real time from facebook, and then joining them against SQL tables.

For that I am usually using .Contains(friends) where friends are the User IDs. the problem is that LINQ will not be able to use .contains(friends) when friends are more than 2100 values and I am getting an exception.

So my question is - what is the best practice for reading on the fly the user's friends and joining that with my SQL tables?

Thanks y'all!

Upvotes: 0

Views: 355

Answers (1)

usr
usr

Reputation: 171178

Issue multiple queries, each querying at most 2100 values. The problem that you are seeing is that SQL Server can only accept 2100 SQL parameters per query batch.

In that sense your problem has nothing to do with Facebook. It is a SQL Server limitation triggered by the type of query that LINQ to SQL decides to send (and there is no way to make it send the query differently).

Upvotes: 2

Related Questions