|
|
I encountered a problem: I have define the field "ProjectSponsor" in PartRecord and Part, and add the column to the DB thru migaration file. And in the cshtml:
...@Html.LabelFor(m => m.ProjectSponsor, T("Project Sponsor: "))
<select id="@Html.FieldIdFor(m => m.ProjectSponsor)" name="@Html.FieldNameFor(m => m.ProjectSponsor)">
@Html.SelectOption(Model.ProjectSponsor, "1", T("Lorry").Text);
@Html.SelectOption(Model.ProjectSponsor, "2", T("Floyd").Text);
@Html.SelectOption(Model.ProjectSponsor, "3", T("Jeff Jin").Text);
</select>
...
And I debug in the EditPost method:
dynamic model = _services.ContentManager.UpdateEditor(contentItem, this);
...
_services.ContentManager.Publish(contentItem);
When I run after the "dynamic model = _services.ContentManager.UpdateEditor(contentItem, this);", I thru the quick watch windows I found the "model" has get the "ProjectSponsor" value, but in the end it save failed, I mean no
exception throwed, but in the table of Database, the value still be null.
I have cost some time on it, but no idear, how do you think about it?
|
|
|
|
And then I delete the table, re-create table still can't insert/modify successful, at last I try to drop the Database, re-create the DB, it can work well, it must the relationship between part field and Table field can't be reflection, but what I need to
do it? Or something other where I did wrong?
|
|
Coordinator
Dec 3, 2012 at 7:07 PM
|
There has to be an exception. Attach a debugger and step through the code.
|
|
|
|
I don't enable the "Migaration" model, I don't know if it cause the problem? Or if there exists other module I need to enable to make sure change will be used for migaration?
|
|
Coordinator
Dec 4, 2012 at 1:00 AM
|
I'm sorry, I don't understand what you mean.
|
|
|
|
I mean in the admin page, I click the "Modules" link and navigate to the Module List page, I found the feature of "Migaration" and "Database Update" isn't enabled, so I think save failure may be for
the feature isn't enabled. Am I right?
|
|
Coordinator
Dec 4, 2012 at 6:54 AM
|
No those are unrelated to your problem and don't need to be enabled. They are for the command line only.
|
|
|
|
bertrandleroy, thank you for reply. I have another problem want to ask you: I want to record user operation(to log operation to DB), I define a record entity:
public class StatusChangeHistoryRecord {
public virtual int ItemID { get; set; }
public virtual string CSType { get; set; }
public virtual int SubmitterID { get; set; }
...}
On the migration file I create the table, and it create table succefully. Then I create a service:
private readonly IRepository<StatusChangeHistoryRecord> _logRepository;
(I get it in the service constructor)
public void AddHistoryRecord(int pContentItemID, CSType pCSType, DateTime pChangeDate, int? pOldStatus, int pCurrentStatus, ContentItem pItem) {
StatusChangeHistoryRecord record = new StatusChangeHistoryRecord();
record.ItemID = pContentItemID;
record.CSType = pCSType.ToString();
...
_logRepository.Create(record);
_logRepository.Flush();
}
after run, I got the exception "No persister for: Levis.Leaves.Core.Models.StatusChangeHistoryRecord", I know it means the model don't mappting to the table in the DB, what I should do?
|
|
|
|
And I can't in the handler used Filters.Add(StorageFilter.For(repository)), because the record don't inherit the ContentPartRecord.
|
|
|
|
I have find the reason: If a record don't inherit the ContentPartRecord, it must declare a property "Id", only do that, it will be mapped to table in the DB.
|
|