Link to home
Start Free TrialLog in
Avatar of Aquarus
Aquarus

asked on

Ling SQL and Count in C#

Please see the attached document
FunctionUsesFunction.docx
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

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.
Avatar of Aquarus
Aquarus

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Aquarus

ASKER

I replaced the linq with the Stored procedure and changed the model.  It works now.