c# MVC - inheritance and interfaces -


i'm new this. please bear me.

i have class called crmobject inherited few other classes contact. want code interface use child-classes of crmobject. need unity.mvc repositories. right have interface each child-class, there should better way , that's why i'm here. glad links , examples this.

pocos:

public class crmobject {     [key]     [column(order = 0)]     public int id { get; set; }     public bool isprocessed { get; set; }     public string error { get; set; }     public long partneroid { get; set; }     public ordnungsbegriffetypetype ordnungsbegrifftyp { get; set; }     [required]     public string ordnungsbegrifftypstring { get; set; }     public string ordnungsbegriffwert { get; set; }     public crmjob job { get; set; }     [foreignkey("job")]     [column(order = 1)]     public int jobid { get; set; } }  [table("contacts")]     public class contact: crmobject     {         public datetime kontaktam { get; set; }         public string erstelltvon { get; set; }         public datetime erstelltam { get; set; }         public string vorlage { get; set; } }  [table("tasks")]     public class task: crmobject     {         public long aufgabeoid { get; set; }         public string externeid { get; set; }         public string aufgabendefinitionsname { get; set; } } 

interface:

public interface icrmobjectrepository {     void add(crmobject o);     void addrange(ienumerable<crmobject> o);     void remove(int crmobjectid);     ienumerable<crmobject> getobjectsbyjobid(int crmjobid);     crmobject findbyid(int crmobjectid); } 

i'd example not use crmobject-type parameter add function, children of crmobject, too.

maybe i'm wrong , way want stupid, impossible or both. i'd love people more experience give me hints on how best. if there additional information needed ask it.

thanks in advance

look generics in c#. https://msdn.microsoft.com/en-us/library/512aeb7t.aspx

basically interface this:

public interface icrmobjectrepository<t> t: crmobject    {     void add(t o);     void addrange(ienumerable<t> o);     void remove(int crmobjectid);     ienumerable<t> getobjectsbyjobid(int crmjobid);     tfindbyid(int crmobjectid); } 

notice t: crmobject. constraint.

https://msdn.microsoft.com/en-us/library/d5x73970.aspx


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -