Relative Content

Tag Archive for c#parametersinterface

How do I pass Interfaces as an Interfaces parameter

I am designing an application that reads and writes to a sql server database. I have multiple classes that are simply an instance of a table record (is this correctly called a model?) I want to create an interface (IDataModel) for the models to use. I also want to create an interface (IDataModelUpdatable) that contains update method signatures to be implemented by those models that will update to the DB using IDataModel as the parameter types. The problem I run into is that when I implement the IDataModelUpdatable methods, I cannot use the properties of the model because they are not in IDataModel. Each model has unique properties that need to be reference. It is my understanding that the purpose of Interfaces is to be able to interchange objects as long as they implement the same interface. Is there a way to use IDataModel as the parameter, but reference the actual class’s properties?