c# - Any type mapping with different Id types -
i'm working on event-planning application contacts in phone book. avoiding public virtual
, protected
stuff, contact
class looks like:
class contact { //... int32 id { get; private set; } //primary key; string name { get; private set; } //... }
a customer asked me handle both own phone book , application's one. thought extract icontact
interface contact
, , add class internalcontact
(this name sucks, know), implementing same interface. problem customer's db uses assigned string primary key, contact
''s id type , internalcontact
's id type different. possible map invitation.contact
property using <any>
type mapping, id types different?
thanks in advance, giulio
not sure if asking create classes:
interface icontact<t> { t id { get; } } public class contact : icontact<int> { public int id { get; private set; } } public class internalcontact : icontact<string> { public string id { get; private set; } }
Comments
Post a Comment