在 Silverlight 4 中获取用户配置文件数据
我对 Silverlight 和 RIA 服务相当陌生,我正在尝试构建一个小项目来理解它。所以基本上我创建了一个业务应用程序,并且我有正常的登录屏幕,我可以在其中添加用户。没关系,我可以添加一个用户并将其添加到 aspnet_Users 表中。现在我创建了一些额外的字段,例如 Mob No、Tel No、DOB、Locality 等,我将其放入我创建的名为 UserProfile 的表中,我的想法是获取注册的用户名,并将其插入到我的 UserProfile 表以及其他相关数据。
因此,我创建了一个名为 Profile.xaml 的页面,创建了一个 UserProfileDomainService.cs,其中只有一个查询,用于从表中获取用户配置文件数据,然后在我的页面上创建一个详细信息 DataGrid,在我的情况下,QueryName 是GetUserProfilesQuery()。现在我想做的是,让用户登录,获取他的用户名,然后检查我的表以查看表中是否已有数据。如果有,则用数据填充 DataGrid 上的字段,以便用户可以修改此数据,如果没有,则允许用户将数据插入表中。
因此,我创建了一个 UserProfileViewModel 类,并且我想创建查询来获取与该用户相关的数据。然而,我陷入了如何完成所有这些以及如何让用户登录的困境。
任何人都可以给我一些建议或向我指出一些关于如何实现这一目标的教程吗?
非常感谢,非常感谢您的帮助。
I am fairly new to Silverlight and RIA services, and I am trying to build a small project to understand it. So basically I created a Business Application, and I have the normal Login screen where I can add a user. That is fine and I can add a user and get him into the aspnet_Users table. Now I have created some extra fields, like Mob No, Tel No, DOB, Locality etc, which I have put in a table I have created called the UserProfile, and my idea is to get the username that was registered, and insert it into my UserProfile table with the other relevant data.
So I created a page called Profile.xaml, I created a UserProfileDomainService.cs where I have just one query, to get the user profile data from the table, and then created a Details DataGrid on my page, and the QueryName in my case is GetUserProfilesQuery(). Now what i wish to do is, get the user logged in, get his username, and check in my table to see if there is already data in the table. If there is populate the fields on the DataGrid with data, so that the user can modify this data, and if not, allow the user to insert data into the table.
So I have created a UserProfileViewModel class, and I want to create the query to get the data relevant to this user. However I got stuck on how to do all this, and how to get the user logged in.
Can anybody give me some advice or point me to some tutorials on how I can achieve this?
Thanks a lot and your help is very much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在域服务查询中,您可以使用 ServiceContext.User.Identity.Name 获取特定于该用户的信息以包含在数据库查询中。我在我们的项目中做了类似的事情。
我们使用实体框架,因此 LINQ to Entities 查询如下所示:
In your domain service query you can use ServiceContext.User.Identity.Name to get the information specific to that user to include in your db query. I do something similar in our project.
We use entity framework so the LINQ to Entities query looks like: