Hi Neil

 

I thought I had this Entity SQL problem solved, but two steps forward and
one backward (as usual). You can't construct an ObjectParameter with a name
and null value, you have to give a type like this:

 

ObjectParameter param = new ObjectParameter("MyNum", typeof(int));

 

I can understand that that parameter must be given a type before it's added.
This leaves the value null and it allowed me to use the parameters with null
values like this inside a WHERE clause:

 

((@OwnId IS NULL) OR (i.OwnId=@OwnId)) AND

((@MedId IS NULL) OR (v.MedId=@MedId))

 

This is just what I want, a large general purpose WHERE clause that deals
nicely with null parameters. I was all excited, but the parameters so far
were all integers, and then I appended this string parameter to the clause:

 

... AND
((@Title IS NULL) OR (v.Title=@Title))

 

This causes a terrible SQL CE error I experienced last year when writing
plain ADO.NET for SQL CE and I did not add the parameters in exactly the
correct way:

 

System.Data.SqlServerCe.SqlCeException The specified argument value for the
function is not valid. [ Argument # = 1,Name of function(if known) = isnull
]

 

So I'm stuck in a log jam again and searching the web.

 

Greg

Reply via email to