Dynamic Linq Execute Functions inside of Select Statement

c# dynamic-linq function

Question

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
0
10/22/2014 5:15:43 PM

Accepted Answer

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)

1
10/22/2014 5:26:00 PM


Related Questions





Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow