问题描述
我有一个声明的函数: 我如何从动态Linq中的Select语句执行此语句我试过了。
pre $ public static string GetFormattedLink(string ExtTitleID)
{
returnStr_+ ExtTitleID;
$ b $ p
$ b
使用(var Model = new MK3Entities())
{
var TOrigin =(Model.Titles .Where(ID> 19632)
.Select(new(ID,GetFormattedLink(ExtTitleID)))
as System.Collections.IEnumerable)
.Cast< dynamic>( )。取(10).ToList();
$ b然而,这会返回异常:没有适用的方法'GetFormattedLink'存在于'标题'类型中。
如何在Select中格式化我的结果?
解决方案看起来范围是在没有GetFormattedLink的标题上,如果它不在Title类上,请尝试使用完整名称空间调用该方法(或者将它移动到标题类if那就是它的所在)
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?
解决方案 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)
这篇关于动态Linq在Select语句中执行函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!