Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interface for Linq-To-Sql Entities

This is a pretty straight-forward question. I was wondering if there is some kind of interface I could use to represent any of the entities returned by my Linq-To-Sql dbml?

So I could let's say return things such as IQueryable and it could simply get casted back in its right entity afterward for example?

Thanks!

like image 428
Tommy B. Avatar asked Jun 08 '26 04:06

Tommy B.


1 Answers

You can change the code generation for your Linq to Sql entities. Here you can find T4 templates for Linq to Sql.

If you use those, you can let all entities implement a specific interface.

Or you could implement the interface in another code file on the partial class for each entity.

like image 131
Wouter de Kort Avatar answered Jun 10 '26 16:06

Wouter de Kort



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!