У меня возникают проблемы с получением и установкой значения, потому что я ввел третий код в свой код.Попытка получить/установить запись
Раньше я хотел бы сделать это, чтобы получить/установить в записи:
public virtual string MyString { get; set;}
, а затем в моей части:
public string MyString
{
get { return Record.MyString; }
set { Record.MyString = value; }
}
и NHibernate бы сохранить свои ценности в БД (очевидно мои другие код не приводится здесь для краткости).
Теперь я пытаюсь установить флажок со списком. Я это за флажком:..
public class MyPart : ContentPart<MyPartRecord>
{
public MyPart()
{
MyList = Enum.GetValues(typeof(MyEnum))
.Cast<MyEnum>().Select(x =>
{
return new SelectListItem { Text = x.ToString().ToUpper(),
Value = ((int)x).ToString() };
}).ToList();
}
public IList<SelectListItem> MyList { get; set; }
private string myCheckBox;
// Record class contains the following commented code:
// public virtual string MyCheckBox { get; set;}
// Trying to do this now here in MyPart class:
public string MyCheckBox
{
get
{
if (!string.IsNullOrEmpty(myCheckBox))
return myCheckBox;
// Tried the following commented code to get value:
// Record.MyCheckBox = myCheckBox;
return string.Join(",", MyList.Where(x => x.Selected)
.Select(x => x.Value).ToArray());
}
set
{
myCheckBox = value;
// Tried the following commented code to set value:
// Record.MyCheckBox = myCheckBox;
}
}
}
Я просто не знаю, как присвоить значения в этом случае (получение/установка myCheckBox
в MyCheckBox
Это сохраняются в БД, как нуль
Спасибо заранее за любую помощь.
Попробуйте 'Record.MyCheckBox = value' –
@DStanley Я пробовал это несколько дней назад :) – REMESQ