0


I have a list with an externa content type.
I am tring to fetch the element by server side code, but i get this exception:

Microsoft.BusinessData.Infrastructure.BdcException

This is my code:

SPList myList = Web.Lists["listaName"];
SPListItem item = (from SPListItem item in myList.Items
                      where Convert.ToString(item["BdcIdentity"]) == myID
                      select item).ToList().FirstOrDefault();
0

Solded wrapping my code into Usings (probably the Context was missing)

using (SPSite site = new SPSite(Web.Site.ID))
{
    var context = SPServiceContext.GetContext(site);
    using (var scope = new SPServiceContextScope(context))
    {
        using (Web)
        {
            //my code
        }
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.