Ling SQL and Count in C#

Please see the attached document
FunctionUsesFunction.docx
AquarusAsked:
Who is Participating?
 
Fernando SotoRetiredCommented:
First is my assumption correct? Is that the error you are getting?
0
 
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.
0
 
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.
0
 
AquarusAuthor Commented:
I replaced the linq with the Stored procedure and changed the model.  It works now.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.