This project has moved and is read-only. For the latest updates, please go here.

Schema Extension Problem

Topics: Developer Forum
Jun 7, 2007 at 8:11 PM

I've integrated the Basic Web Player sample application with my LMS. I also extended the base MLC schema to include some custom fields. Namely, I've included a 'PersonId' field in the UserItem table in order to integrate the MLC database with an existing corporate database. The problem I'm running into is accessing this field using the standard MLC query mechanisms. I've provided code below. You'll notice I'm trying to insert the PersonId into the UserItem record. However, I'm receiving at runtime a System.InvalidOperationException from the job.AddOrUpdateItem method, that complains that the property "PersonId" cannot be found. Stack trace is below the code below. Of particular importance is that I added the field to the table after I created the database. I did, however, rebuild the schema and regenerated the Schema.cs file, so the property does exist in the Schema source code - otherwise I'd be getting a compile error. Spelling is all correct; the data type is 'int'. Thank you for your prompt response.

protected LStoreUserInfo GetCurrentUserInfoResults(DataTable dataTable)
DataRowCollection results = dataTable.Rows;
LearningStoreJob job = LStore.CreateJob();
UserItemIdentifier userId;
string userName;
if (results.Count == 0)
// the user isn't listed in the UserItem table -- add them...

// set <userName> to the name of the user that SCORM will use
#if false
// the following code queries Active Directory for the full name
// of the user (for example, "Karen Berg") -- this code assumes a
// particular Active Directory configuration which may or may not
// work in your situation
string adsiPath = String.Format("WinNT://{0},user",
UserIdentity.Name.Replace(@"\", "/"));
using (DirectoryEntry de = new DirectoryEntry(adsiPath))
userName = (string)de.Properties"FullName".Value;
// the following code uses the "name" portion of the user's
// "domain\name" network account name as the name of the user
userName = UserName;
int backslash = userName.IndexOf('\\');
if (backslash >= 0)
userName = userName.Substring(backslash + 1);

// create the UserItem for this user in LearningStore; we use
// AddOrUpdateItem() instead of AddItem() in case this learner
// was added by another application between the check above and
// the code below
job = LStore.CreateJob();
Dictionary<string, object> uniqueValues =
new Dictionary<string, object>();
uniqueValuesSchema.UserItem.Key = UserKey;
Dictionary<string, object> addValues =
new Dictionary<string, object>();
addValuesSchema.UserItem.Name = userName;
addValuesSchema.UserItem.PersonId = this.personId;
uniqueValues, addValues, null, true);
userId = new UserItemIdentifier(job.Execute<LearningStoreItemIdentifier>());
// return a LStoreUserInfo object
return new LStoreUserInfo(userId, userName);

System.InvalidOperationException: Property 'PersonId' not found
at Microsoft.LearningComponents.Storage.LearningStoreJob.AddOrUpdateItem(String itemTypeName, IDictionary`2 uniquePropertyValues, IDictionary`2 propertyValuesToUpdate, IDictionary`2 propertyValuesForAdd, Boolean requestItemId) in c:\dev\Juma10\Src\Storage\LearningStore\LearningStoreJob.cs:line 2023
at Teams.MLC.PageHelper.GetCurrentUserInfoResults(DataTable dataTable) in C:\Source\Teams\Teams\MLC\PageHelper.cs:line 304
at Teams.MLC.PageHelper.GetCurrentUserInfo() in C:\Source\Teams\Teams\MLC\PageHelper.cs:line 325
at Teams.MLC.PageHelper.GetUserInfo(Int32 person) in C:\Source\Teams\Teams\MLC\PageHelper.cs:line 333
at Teams.MLC.SCORMFileUploader.SaveNewFile() in C:\Source\Teams\Teams\MLC\SCORMFileUploader.cs:line 46