执行命令定义时发生错误

时间:2015-06-11 23:50:27

标签: c# entity-framework

以下方法抛出异常(执行命令定义时发生错误)

public static List<NameAndValue> GetCodes(SearchTextRequest searchTextRequest)
{

    using (var db = new ToolsCommonEntities())
    {
        if (searchTextRequest != null && !string.IsNullOrEmpty(searchTextRequest.SearchText))
        {
            return db.Codes.Where(x => x.Code.Contains(searchTextRequest.SearchText)).Select(x => new NameAndValue { Name = x.Code, Value = x.CodeType }).Distinct().ToList();
        }
        else
        {
            return db.Codes.Select(x => new NameAndValue { Name = x.Code, Value = x.CodeType }).Distinct().ToList();

        }
    }
} 

这个方法能够很好地从代码表中获取值。但是,当我开始使用c#服务填充“代码”表中的值时,上述错误开始发生。

问题:

当另一个服务在其中填充值时,如何从'Codes'表中读取值?任何建议都表示赞赏。

0 个答案:

没有答案
相关问题