1

I know this question is similar to others but they have not provided me with an answer so far. I have an array of numbers in javascript which i pass back to my controller, Each number is an id for an object in the db which i will pull out and load into a jqgrid. The issue im having is with the query. I pass back the array and then call the function below in my repository.

public IQueryable<IOSSample> getSamplesForSamplePoints(Array samplePointIds)
    {
        return (from u in context.IOSSamples
                where samplePointIds.Contains(u.IOSSamplingPointId)
                select u);
    }

However the function does not like me using contains so im not sure how to go about this, any help would be much appreciated.

3
  • what is the error exactly? Maybe you need to type your parameters, try to use ICollection<int> instead of Array? Commented Sep 8, 2015 at 14:30
  • Is the Array of samplePointIds the same type as u.IOSSamplingPointId? Commented Sep 8, 2015 at 14:31
  • can you not use int[] samplePointIds instead? Commented Sep 8, 2015 at 14:33

1 Answer 1

3

If u.IOSSamplingPointId is an int, you need to use a typed array as your function input parameter:

public IQueryable<IOSSample> getSamplesForSamplePoints(ICollection<int> samplePointIds)
{
    return (from u in context.IOSSamples
            where samplePointIds.Contains(u.IOSSamplingPointId)
            select u);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.