문제

다른 속성이있는 Business Object가 있다고 가정합니다. 읽기 전용.예 :

public class Order
{
     ...
     public DateTime OrderDate { get; set; }
     ...
     public decimal OrderTotal { get; set; }
}
.

또한 OrderTotal이 응용 프로그램에서 설정할 수없는 저장된 proc에 의해 반환되는 계산 된 값이라고 가정합니다 (주문 계수 수 있습니다).일반적으로 나는 공공 세터없이 주문을 작성하기 만하면됩니다.

public decimal OrderTotal { get; private set; }
. 그러나

그러나 그렇게하면 bltoolkit이 더 이상이 속성의 값을 설정하지 않습니다.나는 또한 이미 이것을 내부 재산으로 써서 친구 조립으로 Bltoolkit을 정의하려고 노력했습니다. (InternalsVisibleTo("BLToolkit.4, PublicKey=xyz")) 성공하지 못한다.

Bltoolkit에서 여전히 채워질 수있는 공개 세터없이 속성을 작성할 수 있습니까?

도움이 되었습니까?

해결책

There is a Storage Property on the MapField Attribute, maybe that will help

    public class Class1
    {
        int _int32 = 0;
        [MapField(Storage = "_int32")]
        public int Int32
        {
            get { return _int32; }
        }
    }

다른 팁

I don't think you can do that, but if I understand you correctly you don't need it. If OrderTotal is returned from stored procedure than it is just fine if you leave it as it is. Unless Order class is representing the actual Order table in the database, you won't have any problem if you accidentally update OrderTotal.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top