InstantAPIs icon indicating copy to clipboard operation
InstantAPIs copied to clipboard

IModel

Open ChessGeekBoy opened this issue 2 years ago • 5 comments

It might be nice if the user was allowed to inherit their model from an IModel interface that looked something like this:

interface IModel
{
    int/Guid Id { get; set;}
}

This would allow the code not to have to use the Type.GetProperty() method and provide more IntelliSense.

ChessGeekBoy avatar Mar 11 '22 01:03 ChessGeekBoy

As we're working with entities I would go with:

public interface IEntity { }
    
public interface IEntity<TId> : IEntity
{
    public TId Id { get; set; }
}

Also pretty sure you can derive your model from that interface and it should just work in it's current form.

ScottKane avatar Mar 24 '22 00:03 ScottKane

Sure, that would be better.

ChessGeekBoy avatar Mar 24 '22 01:03 ChessGeekBoy

Thinking this through... if this interface was implemented by a class and a collection, how do you see this applying to the APIs?

This feels like it plays in the same space as the #4 Repository support.

Thoughts?

csharpfritz avatar Apr 04 '22 18:04 csharpfritz

Yeah I would agree this kind of falls into repository pattern territory

ScottKane avatar Apr 05 '22 17:04 ScottKane

Yeah, I think this is the same thing as Repository support. This (or repository support) would allow the client/user to get a compilation error if their Model does not contain an Id property rather than getting an exception thrown during Type.GetProperty().

ChessGeekBoy avatar Apr 10 '22 05:04 ChessGeekBoy