sharepoint.linq.dll无法使用指定的强制转换

问题描述 投票:1回答:1

我正在编写代码来检查一个项目是否存在于sharepoint文档库中,我使用sp metal生成了实体类。代码如下:

public bool? checkRSA(string pin)
    {
        bool ?checkIfRsaExists = null;
        SPSecurity.RunWithElevatedPrivileges(delegate ()
        {
            string siteURL = "http://dms.site.com/sites/DirOperations/CustomerCare";
            CustomercareDataContext CustCareDB = new CustomercareDataContext(siteURL);
            checkIfRsaExists = CustCareDB.GetList<BenefitsCT>("RSAs Library").ScopeToFolder("", true).Any(x => x.RSAPIN == pin);
        });
        return checkIfRsaExists;
    }

现在每次运行此代码时都会抛出错误:指定的强制转换无效。

堆栈跟踪如下:

StackTrace at Set__permi(Object,Object)\ r \ n在Microsoft.SharePoint.Linq.SPItemMappingInfo.MaterializeEntity [TEntity](DataContext dc,SPDataList list,SPListItem item,SPItemMappingInfo itemMappingInfo,JoinPath joinPath)\ r \ n在lambda_method(Closure, SPListItem)\ r \ n在System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext()\r\n at System.Linq.Enumerable.Any[TSource](IEnumerable1 source,Func`2谓词)\ r \ n在Microsoft.SharePoint.Linq.SPLinqProvider.Execute [T](表达式表达式)\ r \ n在linkApprovals.WebService1 。<> c__DisplayClass2_0.b__0()位于c:\ users \ sp_admin \ documents \ visual studio 2015 \ Projects \ linkApprovals \ linkApprovals \ WebService1.asmx.cs:第75行\ r \ n在Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess (CodeToRunElevated secureCode)“string

c# linq sharepoint linq-to-sql
1个回答
0
投票

我能够弄清楚这一点。事实证明,SP Metal生成的上下文文件已损坏。堆栈跟踪指出了解决方案。我删除了__permi(对象,对象),它工作得很好。

© www.soinside.com 2019 - 2024. All rights reserved.