How to call a method in the where clause of a LINQ query on a IQueryable object?

This should work in Linq to Objects if GetDistance() returns a boolean - it will not work with Linq to Entities since it will try to map your method to a SQL equivalent, which of course there is none As a crude workaround you could use AsEnumerable() but that would materialize all your types so is not recommended if your table is larger: myTypes = myTypes.AsEnumerable() . Where(x => GetDistance(x. Zip, givenZip) Of course if you are restricted to just SQL Server you could just use a store query directly to use geo-locations - but that would work around EF.

This should work in Linq to Objects if GetDistance() returns a boolean - it will not work with Linq to Entities since it will try to map your method to a SQL equivalent, which of course there is none. As a crude workaround you could use AsEnumerable() but that would materialize all your types so is not recommended if your table is larger: myTypes = myTypes.AsEnumerable() . Where(x => GetDistance(x.

Zip, givenZip).

Those newly supported spatial data types will be supported in . NET 4.5. They are not yet supported in any release suitable for production. – Ladislav Mrnka Oct 25 at 12:39 @LadislavMrnka: gaah!

Will edit – BrokenGlass Oct 25 at 12:40.

This will throw an error because the runtime tries to convert your expression tree into SQL. The function 'GetDistance' cannot be converted. Have a look at Model Defined Functions.

They allow you to define a custom function in your edmx which you can execute when building queries.

Assuming: List myTypes; try: myTypes = myTypes. Where(x => GetDistance(x. Zip, givenZip).

C# - How to call a method in the where clause of a LINQ query on a IQueryable object - Stack Overflow.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions