Tell me more ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I've been using a helper dll for quite some time to interact with various BCS Entities. It works rather well, no security issues, saves me a lot of time. The problem that I have is that I want to start creating, updating, and deleting. However I need to do this all in code as this specific process is all running from a Timer Job.

I found a guy who directed me to the Delete method that simply requires the Identity; pretty simple. However I trying to now create the "Create" and "Update" methods. I've got most of it and i'll post a snippet. The IView, then I get the default values and population the IFieldValueDictionary. All the examples show hardcoded field names, no looping. The IFieldValueDictionary states it doesn't cotain a public definition for "GetEnumerator". I just wanted to write a KeyValuePair loop but it's not a normal iDictionary item. So before I and possibly reinvent the wheel, I was wondering if anyone else out there has done this before and could explain how.

      //*** Microsoft Example
      IView createView = entity.GetCreatorView("CreateCustomer");
      IFieldValueDictionary valueDictionary = createView.GetDefaultValues();

      // Set the values of the entity fields.
      valueDictionary["EmailAddress"] = Email.Text;
      valueDictionary["FirstName"] = FirstName.Text;
      valueDictionary["LastName"] = LastName.Text;
      valueDictionary["MiddleName"] = MiddleName.Text;
      valueDictionary["Phone"] = Phone.Text;
      valueDictionary["Title"] = Title.Text;

      // Call the creator method and display the returned
      // Customer ID.
      Identity id = entity.Create(valueDictionary,
        LobSysteminstance);

      CustomerID.Text =
        id.GetIdentifierValues().GetValue(0).ToString();`

My Example:

IView _createIView = _iEntity.GetCreatorView(_methodInstanceName);
IFieldValueDictionary _iFieldValueDict = _createIView.GetDefaultValues();

foreach (KeyValuePair<Object,Object> IFieldValue in _iFieldValueDict) {

}

Identity _identity = _iEntity.Create(_iFieldValueDict,_iLobSystemInstance);
share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.