是否可以使用Linq更改数据库表? [英] Is it possible to use Linq to ALTER a database table?

查看:83
本文介绍了是否可以使用Linq更改数据库表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图以编程方式在Access数据库内的表中删除一列,但发现自己无法这样做!有可能吗?这让我认为我对linq to sql 做不到所做的事情一无所知。
有什么想法吗?

I am trying to programmatically drop a column in a table inside of an access database and found myself unable to do so! Is it at all possible? it makes me think that i don't have any clear idea of things linq to sql can't do. Any ideas?

推荐答案

在LINQ to SQL中没有什么可以让您无需编写T-SQL就能做到的,

There's nothing in LINQ to SQL that allows you to do that without writing T-SQL, no.

类似地,如果不首先选择要更改的数据并操作对象,就无法进行直接更新或删除。您必须为这些事情编写存储过程,并将它们添加到要调用的模型中。请参见此MSDN页面以获取概述。

Similarly, you can't do straight updates or deletes without selecting the data you want to alter first and manipulating the objects. You'd have to write stored procedures for those things and add them to your model to be called. See this MSDN page for an overview.

使用如果您不介意源代码中使用T-SQL,则DataContext.ExecuteQuery 也应该起作用。

这篇关于是否可以使用Linq更改数据库表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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