Quantcast
Channel: EntityFramework Reverse POCO Code First Generator
Viewing all articles
Browse latest Browse all 1642

New Post: Add marker interfaces to certain POCO classes

$
0
0
I would like to be able to mark some of my generated POCOs with a marker interface that guarantees they implement a given property.

For example;
public interface IHasCode
{
    string Code { get; }
}

// Generated:
public class Employee : IHasCode
{
    public Guid Id { get; set; }
    public string Code { get; set; }    
}
There are a couple of ways I can think of:
  1. Make all generated classes partial, so I can create another file for those I want to, and add the interface there.
  2. Have the generated code implement the interface for those POCOs that meet a certain criteria (regex wouldn't cut it - it'd have to be a Func<[class definition], bool> or something that allows me to inspect the properties and see if there's a column called "Code").

Viewing all articles
Browse latest Browse all 1642

Trending Articles