Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does LINQ to SQL support POCO?

Tags:

linq-to-sql

If I want to work with an object and leverage LINQ to SQL what (if anything) do I need to add to my entity classes to ensure my application can talk to the data store? (keep out any discussion of repository patterns here as I'm just looking for what is required inside my business objects)

like image 244
Toran Billups Avatar asked Mar 26 '26 03:03

Toran Billups


1 Answers

Besides using the LINQ-to-SQL designer and having it create the "almost POCO" classes for you (decorated with a bunch of attributes for the mapping), you can also use an external mapping XML file (much like NHibernate) to achieve the same thing, thus allowing you to support "true POCO" classes without any additional attributes or anything.

See here for more information:

  • External Mapping Reference (LINQ to SQL)
  • Linq to SQL - Mapping Tables to Objects
  • Using External Mapping File With Linq To SQL DataContext

Marc

like image 150
marc_s Avatar answered Apr 01 '26 04:04

marc_s



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!