Accessor is inaccessible

Mar 30, 2010 at 12:58 PM

I have table which have three foreign key  fields. i want to set these fields from my code. like this :

ClientDocuments cd = new ClientDocuments();
            cd.BorrowerId = CurrentClient.ClientId;
            cd.DocumentFileId = df.DocumentFileId;
            cd.ClientDocumentTypeId = Convert.ToInt32(ddlClientDocType.SelectedValue);

It is giving me error 

"Error    2    The property or indexer 'WILMA.DAL.ClientDocuments.BorrowerId' cannot be used in this context because the set accessor is inaccessible    E:\wilma2\WILMA\Controls\LoanManagement\DocumentManagement.ascx.cs    153    13    WILMA"


and generated file is ::

[Field("BorrowerDocumentId", AllowDBNull = false, Identifier = true, AutoNumber = true)]
        public int BorrowerDocumentId
                return _borrowerDocumentId;
            private set
                _borrowerDocumentId = value;

there is private keyword that' why it is not working. what  should i do in this case.


Apr 1, 2010 at 5:38 PM

Well I would just remove the private keyword.

Apr 2, 2010 at 12:05 AM

Yes. As pointed out. Please remove the private keyword. It should work then.

Apr 21, 2010 at 5:08 AM

yes We can delete private keyword. except this we can also make code in particular  this case :

cd.Client = CurrentClient;

Please Note :

1. There is a relation b/w Clientdoc and Client table.

2. Here CurrentClient is property and initialize from client table fields.

hope this will help some people.