惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Help Net Security
博客园 - Franky
GbyAI
GbyAI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
爱范儿
爱范儿
IT之家
IT之家
酷 壳 – CoolShell
酷 壳 – CoolShell
aimingoo的专栏
aimingoo的专栏
博客园_首页
MongoDB | Blog
MongoDB | Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recent Announcements
Recent Announcements
Scott Helme
Scott Helme
有赞技术团队
有赞技术团队
M
MIT News - Artificial intelligence
C
CERT Recently Published Vulnerability Notes
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Jina AI
Jina AI
F
Fortinet All Blogs
N
Netflix TechBlog - Medium
L
LangChain Blog
L
LINUX DO - 最新话题
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
H
Hacker News: Front Page
MyScale Blog
MyScale Blog
P
Palo Alto Networks Blog
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
AI
AI
T
Troy Hunt's Blog
Microsoft Azure Blog
Microsoft Azure Blog
阮一峰的网络日志
阮一峰的网络日志
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
罗磊的独立博客
S
Secure Thoughts
大猫的无限游戏
大猫的无限游戏
博客园 - 叶小钗
人人都是产品经理
人人都是产品经理
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
Apple Machine Learning Research
Apple Machine Learning Research
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
S
Security @ Cisco Blogs
Cloudbric
Cloudbric
E
Exploit-DB.com RSS Feed
Attack and Defense Labs
Attack and Defense Labs

博客园 - 老姜

SQL Server 2008 收缩日志 【原创】自定义Membership,KSPMembership发布,支持多数据库(mysql/oracle/sqlserver) 日志与工厂模式(二) 日志与工厂模式(一) The timeout period elapsed prior to obtaining a connection from the pool.数据库连接池满的原因 Asp.net mvc 入门介绍(公司内部讲座学习资料) 反射复习(Reflection) SERV-U 防火墙设置 检索 COM 类工厂中 CLSID 为 {000209FF-0000-0000-C000-000000000046} 的组件时失败 的解决方法 ASP.NET MVC 多语言解决方案 C#(ASP.NET)DateTime日期类型格式化显示 (转载) 从SQL SERVER 2000到SQL SERVER 2005 视图中存在 ORDER BY 语句的完全解决方案 一个中型OA系统的架构过程(二) Enterprise Library for .NET Framework 2.0 掌握 ASP.NET 之路:自定义实体类简介(转载-ORM、泛型等) 转载:一个中型OA系统的架构过程(一) WebServices层次划分 SQL SERVER 2000 存储过程不支持数组的解决方法! 通过日志来恢复到你要的时点
DLinq 仅支持SQL SERVER ,不支持Mysql/Oracle
老姜 · 2007-12-19 · via 博客园 - 老姜

    最近使用了visual studio 2008,感觉了一下Dlinq的强大,但是发现Dlinq仅仅能在Sql Server下使用,无法使用其他数据库。如果你在项目中试图拖拽一个非 Sql Server的数据库表到设计窗口上,会报一个不支持类型的错误,即使是 Access也不支持,更不要提MySql了。
    我还发现,自动产生的实体类代码的 System.Data.Linq.DataContext 提供了一些构造函数,

    public partial class BaseEntityDataContext : System.Data.Linq.DataContext
    
{
        
        
private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();
        (省略一些代码)        
public BaseEntityDataContext() : 
                
base(global::IVTrade.Entity.BaseEntity.Properties.Settings.Default.IVTradeConnectionString, mappingSource)
        
{
            OnCreated();
        }

        
        
public BaseEntityDataContext(string connection) : 
                
base(connection, mappingSource)
        
{
            OnCreated();
        }

        
        
public BaseEntityDataContext(System.Data.IDbConnection connection) : 
                
base(connection, mappingSource)
        
{
            OnCreated();
        }

        
        
public BaseEntityDataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
                
base(connection, mappingSource)
        
{
            OnCreated();
        }

        
        
public BaseEntityDataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
                
base(connection, mappingSource)
        
{
            OnCreated();
        }

其中有一个传入 System.Data.IDbConnection 类型的构造函数。那是不是意味着只要我的实体类已经存在了,在进行连接数据库时只要传入一个 System.Data.IDbConnection 类型的参数,就可以操作任意数据库了?答案是否定的。因为当你使用 SubmitChange()方法试图保存到数据库中时,如果传入的 System.Data.IDbConnection 对象不是一个 SqlConnection 的话不会成功。
    我就很奇怪,既然 DLINQ 允许这个构造函数,为何还不行呢?如果不允许那就只允许 Sqlconnnection,为何要这样设计,我猜测是为了将来的扩展吧!虽然现在DLINQ支持的数据库还不多,但是我想微软会继续扩展的。多关注 ScottGu 的Blog吧。那到底后台代码是怎么回事呢?用 Reflector  查看 System.Data.linq.dll ,你会发现事实上 DLinq的SubmitChange()方法在使用一个 IProvider 的接口,而这个接口的代码如下:

internal interface IProvider : IDisposable
{
    
// Methods
    void ClearConnection();
    ICompiledQuery Compile(Expression query);
    
void CreateDatabase();
    
bool DatabaseExists();
    
void DeleteDatabase();
    IExecuteResult Execute(Expression query);
    DbCommand GetCommand(Expression query);
    
string GetQueryText(Expression query);
    
void Initialize(IDataServices dataServices, object connection);
    IMultipleResults Translate(DbDataReader reader);
    IEnumerable Translate(Type elementType, DbDataReader reader);

    
// Properties
    int CommandTimeout getset; }
    DbConnection Connection 
get; }
    TextWriter Log 
getset; }
    DbTransaction Transaction 
getset; }
}


 

 

看见了吧,是 internal 的,如果不是,自己就可以在扩展了。期待微软将来支持其他的数据库,至少要支持Ado.net 中已经支持了的 Oracle 吧。