Is there any chance to run c# method in linq query?
I need to do something like that:
//...
class Match {
public double PrecentageMatching(string s1, string s2) {
//...
return result; // value from 0.0 to 1.0
}
}
//...
string pattern = "nameOfRecord";
var similarRecords = db.Table.Select(
r => Match.PrecentageMatching(r.name, pattern) > 0.5
);
I know that there linq wont know a method PrecentageMatching. But I’m wonder if there is any way to do it?
I’m using Entity framework.
I need to do it without stored procedures and assembly on database side. I dont have access to database.
You first need to fetch the data from the database and only then perform the transformation:
That’s not a problem at all, because you are only transforming the returned data with your method. If you want to use your method to filter the returned data using
Where, you have a problem, because you would first need to return ALL data and filter the data on your client. This might be a problem if the table is big.