Inherited properties are not bound during data binding

I have two interfaces: IAuditable and ITransaction.

public interface IAuditable{
    DateTime CreatedOn { get; }
    string CreatedBy { get; }
 }

public interface ITransaction : IAuditable {
    double Amount{ get; }
} 

And the class that implements ITransaction invokes the transaction.

public class Transaction : ITransaction{
    public DateTime CreatedOn { get { return DateTime.Now; } }
    public string CreatedBy { get { return "aspnet"; } }
    public double Amount { get { return 0; } }
}

When I bind the ITransactions list to a datagrid and use the auto-create columns, only the amount is limited. Created By and CreatedOn are not displayed. Is there a way to get these values ​​during data binding?

+3
source share
1 answer

Interfaces do not define the implementation - they only define the required additional interfaces.

, IAuditable , ITransaction. , ITransaction IAuditable.

- ITransaction , IAuditable. , : " ITransaction". , -, ITransaction IAuditable, , ITransaction -.

.

, , "Is-A" (.. ), "Can-do" ().

+5

Source: https://habr.com/ru/post/1739535/


All Articles