J_shelfwood's avatar

ASP.NET polymorphic relations

Hey guys,

I'm working on a project for school using ASP.NET MVC and I can't seem to find out how to handle a specific database related feature. I figured I'd ask here aswell since some of you come from the ASP.NET C# world and might be able to give me some advice.

Basically we're creating a student learning platform based on Stack overflow. And I'm trying to make a database scheme for the likes on various things, such as questsions, answers and comments. The problem here is that I don't want to make a seperate table for questions, answers and comments, as all can be liked or disliked. In laravel you would handle this with polymorphic relations, you'd create a likable_type and likable_id on the likes table to allow for links to multiple tables. However, I can't find any documentation on Polymorphic Relations for ASP.

Maybe someone can help me with understanding how this is done in ASP.net . What is the best practise for handeling this kinds of tables?

0 likes
2 replies
J_shelfwood's avatar

Thanks for your suggestion, This seems like a suitable solution. Looks very complicated though.

Please or to participate in this conversation.