谁在 silverlight 中创建数据插入操作的自定义方法?
我正在使用 silverlight WCF Ria 服务来处理我的应用程序中与数据库相关的操作。
表,
Post(Id int identity,Title varchar(50), Content varchar(50), Date datetime, Comments varchar(50) );
我确实有一个可以轻松使用的
public void InsertPost( Post post )
{
if ((post.EntityState != EntityState.Detached))
{
this.ObjectContext.ObjectStateManager.ChangeObjectState(post, EntityState.Added);
}
else
{
this.ObjectContext.Posts.AddObject(post);
}
}
我可以使用它来更新数据库,但为此我需要传递所有条目,即 Id、内容等,
我需要另一种方法,通过它我可以跳过传递 Id
价值观。 我想要这个方法而不是 InsertPost
方法,以及如何在我的 submitbutton_click
事件中使用它。
请帮忙
I am using silverlight WCF Ria service to handle database related operations in my application.
I do have a table
Post(Id int identity,Title varchar(50), Content varchar(50), Date datetime, Comments varchar(50) );
I can easily use
public void InsertPost( Post post )
{
if ((post.EntityState != EntityState.Detached))
{
this.ObjectContext.ObjectStateManager.ChangeObjectState(post, EntityState.Added);
}
else
{
this.ObjectContext.Posts.AddObject(post);
}
}
I can use this to update database but for that i need to pass all the entries i.e Id, Content etc
I need one other method through which i can skip passing Id
values.
I want this method other than InsertPost
method and how can i use that in my submitbutton_click
event.
Please help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想使用 RIA 服务创建自定义数据插入方法,此答案可能会帮助您。
但请记住,如果
Comments
、Content
、datetime
...等。在您的数据库中是可为空
,那么您可以使用InsertPost
而不指定它们:If you want to create a custom method for data insertion using RIA Services, this answer might help you.
But remember that if
Comments
,Content
,datetime
...etc. arenullable
in your database, then you could use theInsertPost
without specifying them: