This project is read-only.

Statement never evaluates to true?

Topics: Writing modules
Feb 23, 2011 at 10:32 PM
Edited Feb 23, 2011 at 10:43 PM

Similar to the rewards sample, I am attempting to add in properties to the ContentRewardProgramsRecord.  Mine is called ContentBeltProgramsRecord. 

My properties are not being saved and I debugged it to be this foreach statement in the Service:


foreach (var contentBeltProgramRecord in oldBelts)
                if (lookupNew.ContainsKey(contentBeltProgramRecord.BeltRecord))
                    lookupNew[contentBeltProgramRecord.BeltRecord] = true;
                    var beltRecord = model.Where(r => r.BeltRecord.Id == contentBeltProgramRecord.BeltRecord.Id).First();
                    numOfStripes = beltRecord.NumberOfStripes ?? 0;
                    beltOrder = beltRecord.BeltOrder ?? 0;

This if statement never evaluates to true: 

if (lookupNew.ContainsKey(contentBeltProgramRecord.BeltRecord))
lookupNew is returning a BeltRecord.
contentBeltProgramRecord.BeltRecord is a BeltRecordProxyblahblahblah. Is this true? Should it be a proxy.  I know that, in a sense, it truly is a proxy of the BeltRecord, but I am assuming
that if the ContainsKey is to evaluate as true. It should be a BeltRecord.  Am I miss understanding this if statement?  

One thing I am missing in my db, when a BeltsRecord is created, which is a IList<ContentBeltProgramsRecord>, my BeltRecord_Id is not inserted into the db.

Since I am building a relation to ContentItems, like in the Sponsor Sample.  How the heck do you create a list of LazyField<IContent> for the BeltsRecord?

Feb 24, 2011 at 12:03 AM

Both the items in lookupNew and the BeltRecord should be proxies. I don't know why it's not in your case but you might want to try to lookup by id instead, that might work around it.