LINQ to SQL是否支持POCO? [英] Does LINQ to SQL support POCO?

查看:55
本文介绍了LINQ to SQL是否支持POCO?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我要使用对象并利用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)

推荐答案

除了使用LINQ-to-SQL设计器并让它为您创建几乎POCO"类外(用一堆映射属性装饰),您还可以使用外部映射XML文件(类似于NHibernate)来实现同一目的,从而使您无需任何其他属性或任何东西即可支持真正的POCO"类.

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

马克

这篇关于LINQ to SQL是否支持POCO?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆