次のコードがあります。
using System;
using System.Collections.Generic;
using System.Text;
using ProjectBase.Utils;
namespace EnterpriseSample.Core.Domain
{
public class Notifikasi : DomainObject<string>, IHasAssignedId<string>
{
public string Name { get; set; }
public string Description { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
public DateTime CreatedDate { get; set; }
public string CreatedBy { get; set; }
public DateTime UpdateDate { get; set; }
public string UpdateBy { get; set; }
public void SetAssignedIdTo(string assignedId)
{
Check.Require(!string.IsNullOrEmpty(assignedId), "assignedId may not be null or empty");
// As an alternative to Check.Require, which throws an exception, the
// Validation Application Block could be used to validate the following
Check.Require(assignedId.Trim().Length == 5, "assignedId must be exactly 5 characters");
ID = assignedId.Trim().ToUpper();
}
public override int GetHashCode()
{
return (GetType().FullName + "|" +
ID + "|" +
Name).GetHashCode();
}
}
}
別のクラスで Notifikasi クラスを使用していますがoNoti.ID = "12";
、エラーが発生します。
set アクセサーにアクセスできないため、このコンテキストではプロパティまたはインデクサーを使用できません。
誰でもこれを解決するのを手伝ってもらえますか? (関連する場合は ORM を使用します)。
INotifikasiDao dao = DaoFactory.GetNotifikasiDao();
dao.closeSession();
dao.openSession();
EnterpriseSample.Core.Domain.Notifikasi oNoti = new EnterpriseSample.Core.Domain.Notifikasi();
int no = 1;
oNoti.Name = "ETL Account History";
DateTime startDate = DateTime.Today;
DateTime expiryDate = startDate.AddDays(30);
oNoti.StartDate = startDate;
oNoti.EndDate = expiryDate;
oNoti.Description = "ACC_HIST" + startDate + "Failure";
oNoti.ID = "12"; //this is where the error happens
dao.Update(oNoti);