问题
I'm trying to grab out formatted values from a project.
I have a function declared:
public static string GetFormattedLink(string ExtTitleID)
{
return "Str_" + ExtTitleID;
}
How would I execute this statement from the Select Statement in Dynamic Linq I tried.
using (var Model = new MK3Entities())
{
var TOrigin = (Model.Titles.Where("ID > 19632")
.Select("new(ID, GetFormattedLink(ExtTitleID))")
as System.Collections.IEnumerable)
.Cast<dynamic>().Take(10).ToList();
}
However this returns the Exception: No applicable method 'GetFormattedLink' exists in type 'Title'.
How can I Formatted my results inside of the Select?
回答1:
It looks like the scope is on title which does not have the "GetFormattedLink", try calling that method with the full namespace if it is not on the Title class (or move it to the title class if that is where it belongs)
来源:https://stackoverflow.com/questions/26513247/dynamic-linq-execute-functions-inside-of-select-statement