值未使用 WCF 更新到 EF 4.1 的数据库

发布于 2024-12-22 15:57:58 字数 1336 浏览 0 评论 0原文

我已经执行了这行代码,但该值没有更新。我为此使用了 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

吃不饱 2024-12-29 15:57:58

如果 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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文