Ling SQL and Count in C#

Please see the attached document
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Fernando SotoRetiredCommented:
Hi Aquarus;

To the statement in your document, "I am trying to modify another function to use the function above and receive an error. See the text below:", when trying to help on a question like this it helps to know what the exception message and inner exception message was.

Also in your question title you state Linq SQL, in .Net there are two technologies dealing with Linq and SQL and they are Linq to SQL and Linq to Entity Framework and both work a little different. Which are you working with?

Looking at the second query it looks like you are trying to call a function from a query that will be executed in SQL server and that is not allowed. The reason being that SQL server has no direct access to your local code and therefore does not know how to call the function. So basically you will need to replace the following line in the select clause.

 NumbrOfReviews = reviewCount(ud.UserId, qs.HierarchyID, (long)qs.AccessTypeID)

Open in new window

with another query called a sub query just like the first query.
AquarusAuthor Commented:
Can you please give me a sample based on both functions in my document how to replace?
This reviewCount is a subquery technically
NumbrOfReviews = reviewCount(ud.UserId, qs.HierarchyID, (long)qs.AccessTypeID).

I am newbie in in linq.
Fernando SotoRetiredCommented:
First is my assumption correct? Is that the error you are getting?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AquarusAuthor Commented:
I replaced the linq with the Stored procedure and changed the model.  It works now.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.