Silverlight WCF RIA 服务。检查布尔方法的结果
Silverlight 应用程序使用 WCF RIA 服务连接到 SQL Server 数据库。在将一堆新记录插入表中之前,我应该检查该表是否包含某个字段中具有特定值的任何记录。
我在域服务类中的服务器端方法:
[Invoke]
public bool CheckRec(string nameFilter)
{
bool res = false;
if (this.ObjectContext.MyTest.FirstOrDefault(p => p.Name == nameFilter) != null)
{
res = true;
}
return res;
}
如何在客户端检查方法结果? 我正在尝试如下方式,但需要一些帮助才能正确实现:
MyTestContext testcontext = new MyTestContext();
string tname = savetdlg.TNameTBox.Text;
testcontext.CheckRec(tname).Completed += (df, fg) =>
{
bool notunique = ?????? // how to get result of the method?
if (notunique == true)
{
//todo if record exists
}
else
{
//todo if record doesn't exist
}
};
A Silverlight application uses WCF RIA Services for connection to a SQL Server database. Before inserting a bunch of new records into a table, I should check if this table contains any records with a certain value in one of the fields.
My server side method in Domain service class:
[Invoke]
public bool CheckRec(string nameFilter)
{
bool res = false;
if (this.ObjectContext.MyTest.FirstOrDefault(p => p.Name == nameFilter) != null)
{
res = true;
}
return res;
}
How I could check the method result on the client?
I'm trying the way like the following, but need some help to implement this correctly:
MyTestContext testcontext = new MyTestContext();
string tname = savetdlg.TNameTBox.Text;
testcontext.CheckRec(tname).Completed += (df, fg) =>
{
bool notunique = ?????? // how to get result of the method?
if (notunique == true)
{
//todo if record exists
}
else
{
//todo if record doesn't exist
}
};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嗯,通过以下方式完成:
Well, done in the following way: