可以让EnableUpdate和EnableDelete在EF4 LinqDataSource上工作吗? [英] Can I get EnableUpdate and EnableDelete to work on an EF4 LinqDataSource?

查看:184
本文介绍了可以让EnableUpdate和EnableDelete在EF4 LinqDataSource上工作吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

2年前,我开始使用Linq-To-Sql,但是我公司正在推动我切换到Entity Framework v4。不想在这里进入L2s vs EF参数,请假设我不能切换回L2S。



无论如何,在很好的'L2S' d定义一个gridview或listview,然后定义一个带有EnableUpdate = true,EnableDelete = true和EnableInsert = true的LinqdataSource。我将gridview或listview的DataSourceID分配给linqdatasource和BAM的ID!即时CRUD。



然而,使用EF4,似乎缺少此自动无代码CRUD。从Visual Studio 2010设计屏幕,我的Gridview任务窗口不显示启用编辑或启用删除。这些项目用于出现在我的L2S应用程序中,此外,当我手动添加EnableX = true属性到我的LinqDataSource时,我尝试更新时收到错误:
LinqDataSource使用的数据上下文lds1必须在启用删除,插入或更新操作时扩展DataContext。



那么有没有办法让EF4服从我的EnableUpdate / Delete / />在LinqDataSource上插入命令?



谢谢!

解决方案

的所有 LinqDataSource 是Linq-to-Sql的组件。您必须使用 EntityDataSource 在实体框架之上工作。这可能会解决您的问题。


So I started using Linq-To-Sql about 2 years ago, but my company is pushing me to switch to Entity Framework v4. Don't want to get into the L2s vs EF arguments here, please just assume that I cannot switch back to L2S.

Anyway, in good ol' L2S, I'd define a gridview or listview, then a LinqdataSource with EnableUpdate=true, EnableDelete=true and EnableInsert=true. I'd assign the DataSourceID of teh gridview or listview to the ID of the linqdatasource and BAM! Instant CRUD.

With EF4 however, it seems that this automatic codeless CRUD is missing. From the Visual Studio 2010 Design screen, my Gridview Tasks window does NOT show "Enable Editing" or "Enable Deleting". These items used to appear in my L2S apps, and furthermore, when I manually add the EnableX=true properties to my LinqDataSource, I get an error when I attempt an update: "The data context used by LinqDataSource 'lds1' must extend DataContext when the Delete, Insert or Update operations are enabled."

So is there a way to make EF4 obey my EnableUpdate/Delete/Insert commands on the LinqDataSource?

Thanks!

解决方案

First of all LinqDataSource is component for Linq-to-Sql. You must use EntityDataSource to work on top of Entity Framework. It will probably solve your issue.

这篇关于可以让EnableUpdate和EnableDelete在EF4 LinqDataSource上工作吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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