我有一个项目的简单评级应用程序。主要有三个表:LINQ联盟列如果验证
Item
{
ItemID,
Contents
}
asp_User
{
UserID,
Name
}
Rating
{
RatingID,
ItemID,
UserID,
int Rating
}
我有LINQ代码读取项目:
var q = from item db.Item
select item;
那么我想追加到包含评级的当前认证的每个项目行QA列用户。如果用户未登录或没有经过认证的用户提供评级,结果将为0.
如果有问题,我正在使用SqlMembershipProvider。
例
Q的最终结果应该是这个样子:
[认证]
//The currently authenticated user has commented on Item.ID = 1 and has given it a 9.
q = {ID = 1, Contents = "Whatever", Rating = 9},
//The currently Authenticated user has not commented on Item.ID = 2.
{ID = 2, Contents = "Something", Rating = 0};
[未通过身份验证]
//There is not an authenticated user
q = {ID = 1, Contents = "Whatever", Rating = 0},
//There is not an authenticated user
{ID = 2, Contents = "Something", Rating = 0};