为查询分配角色 [英] assign role to query

查看:85
本文介绍了为查询分配角色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,



i写信寻求帮助,如何使用'string array []'为单个角色分配以下查询:



更新的查询代码:

  public  UserDetail试用版(字符串用户名,字符串密码)
{

string [] Role = new string [] { trial};


var query =( from s db.Subs
join u in db s.sUID上的.UserDetails等于u.uID
其中 s.sExpiryDate > = DateTime 。现在&&
u.uUsername ==用户名&&
u.uPassword ==密码
选择 u ).FirstOrDefault();

if (query!= null
{
// 构建用户并添加相应的试用角色
return new UserDetail(){username = query.uUsername,password = query.uPassword,Role = 试用};
}
其他
{
// < span class =code-comment>找不到用户
return null ;
}

}





我目前在定义参数时遇到问题例如用户名,密码和角色,以及它的输出编译错误不包含用户名的定义如果有人可以就此问题提出建议,我们将非常感激。



请注意,我的数据库服务器中没有角色字段设置。



非常感谢

解决方案

如果你没有每个用户的角色字段,你将如何确定用户所属的角色?

Dear all,

i am writing to seek help, in how do i assign a single role to following query using 'string array []':

Updated query code:

   public UserDetail trial(string username, string password)
{

    string[] Role = new string[] { "trial"};


    var query = (from s in db.Subs
                join u in db.UserDetails on s.sUID equals u.uID
                where s.sExpiryDate >= DateTime.Now &&
                u.uUsername == username &&
                u.uPassword == password
                select u).FirstOrDefault();

    if (query != null)
    {
        // Build a user and add the appropriate Trial role
        return new UserDetail() { username = query.uUsername, password = query.uPassword, Role = "Trial" };
    }
    else
    {
        // No user was found
        return null;
    }

}



I am currently having issue with defining the parameters such as username, password and role, and its outputting compiling error of 'does not contain definition for username' If anyone could advise on this issue, it would be very much appreciated.

Please note, i do not have role field setup in my database server.

Many thanks

解决方案

If you don't have a role field for each user, how are you going to determine which role(s) a user is a part of??


这篇关于为查询分配角色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆