Dynamic Linq Execute Functions inside of Select Statement

c# dynamic-linq function

Question

From a project, I'm attempting to extract formatted data.

I've defined a function:

public static string GetFormattedLink(string ExtTitleID)
{
    return "Str_" + ExtTitleID;
}

How would I carry out the Select Statement in Dynamic Linq that 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();

}

The Exception: No Applicable Method 'GetFormattedLink' Exists in Type 'Title' is returned, however.

What is the best way to format my findings within the select?

1
0
10/22/2014 5:15:43 PM

Accepted Answer

If "GetFormattedLink" is not available because the scope seems to be on the Title class, try using that method with the complete namespace (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