值未使用 WCF 更新到 EF 4.1 的数据库
我已经执行了这行代码,但该值没有更新。我为此使用了 rad 控件。
db.MergeOption = MergeOption.OverwriteChanges;
var c1 = (from c in db.Currency where c.ThreeLetterIsoCode == "1" select c).First();
c1.ThreeLetterIsoCode = "Updatesd";
db.UpdateObject(c1);
db.SaveChanges();
radDataServiceDataSource1.SubmitChanges();
没有例外,但没有更新。
服务是:
public static void InitializeService(DataServiceConfiguration config)
{
// TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.
// Examples:
// config.SetEntitySetAccessRule("MyEntityset", EntitySetRights.AllRead);
// config.SetServiceOperationAccessRule("MyServiceOperation", ServiceOperationRights.All);
config.SetEntitySetAccessRule("*", EntitySetRights.All);
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
}
protected override ObjectContext CreateDataSource()
{
BaazaarDbContext nw = new BaazaarDbContext();
// Configure DbContext before we provide it to the
// data services runtime.
nw.Configuration.ValidateOnSaveEnabled = false;
// Get the underlying ObjectContext for the DbContext.
var context = ((IObjectContextAdapter)nw).ObjectContext;
// Return the underlying context.
return context;
}
我已经插入了一行,它被插入了。请帮忙解决这个问题。
I have did this line of code but the value is not get updated.I have used the rad control for that.
db.MergeOption = MergeOption.OverwriteChanges;
var c1 = (from c in db.Currency where c.ThreeLetterIsoCode == "1" select c).First();
c1.ThreeLetterIsoCode = "Updatesd";
db.UpdateObject(c1);
db.SaveChanges();
radDataServiceDataSource1.SubmitChanges();
There is no exception but it does not get updated.
The service is:
public static void InitializeService(DataServiceConfiguration config)
{
// TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.
// Examples:
// config.SetEntitySetAccessRule("MyEntityset", EntitySetRights.AllRead);
// config.SetServiceOperationAccessRule("MyServiceOperation", ServiceOperationRights.All);
config.SetEntitySetAccessRule("*", EntitySetRights.All);
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
}
protected override ObjectContext CreateDataSource()
{
BaazaarDbContext nw = new BaazaarDbContext();
// Configure DbContext before we provide it to the
// data services runtime.
nw.Configuration.ValidateOnSaveEnabled = false;
// Get the underlying ObjectContext for the DbContext.
var context = ((IObjectContextAdapter)nw).ObjectContext;
// Return the underlying context.
return context;
}
I have inserted a row it get inserted. Please help on this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果 ThreeLetterIsoCode 是关键属性,那么这是设计使然。您无法更改现有实体的关键属性,因为这会更改 OData 不支持的实体标识。
如果 ThreeLetterIsoCode 是普通属性,则上述内容应该有效。在这种情况下,您能否获取请求/响应的痕迹(例如使用 Fiddler)并将其发布到此处?
If the ThreeLetterIsoCode is a key property then this is by design. You can't change a key property of an existing entity, since that would change the entity identity which is not supported in OData.
If the ThreeLetterIsoCode is a normal property then the above should work. In that case could you please grab a trace of the request/response (using for example Fiddler) and post it here as well?