【问题标题】:how to call two fields of the same table using GetRolesForUser using asp.net mvc如何使用 GetRolesForUser 使用 asp.net mvc 调用同一个表的两个字段
【发布时间】:2021-08-17 05:59:58
【问题描述】:

我想向同一张表的另一个字段发送调用,但我不知道该怎么做,因为我只调用一个字段

  public override string[] GetRolesForUser(string username)
    {
        masterEntities db = new masterEntities();
        
  string data = db.registro.Where(x => x.usuario == username).FirstOrDefault().idrol;


        string[] result = { data };
        return result;
    }

【问题讨论】:

    标签: c# asp.net asp.net-mvc asp.net-mvc-4


    【解决方案1】:

    我是这样解决的:

     public override string[] GetRolesForUser(string username)
        {
            masterEntities db = new masterEntities();
            
         string data =
          db.registro.Where(x => x.usuario == username).FirstOrDefault().idrol;
         string data1 =
        db.registro.Where(x => x.usuario == username).FirstOrDefault().lineainvestigacion;
    
    
            string[] result = { data,data1 };
            return result;
        }
    

    在我看来,在 .cshtml 中我是这样显示的:

     @if (User.IsInRole("coordi")&& User.IsInRole("Ingeniería de Software"))
                {
    
    
      ..put code with what it will take permissions
    
    }
    

    【讨论】:

      猜你喜欢
      • 2023-03-13
      • 2018-01-21
      • 1970-01-01
      • 2012-02-03
      • 1970-01-01
      • 2016-08-21
      • 2020-06-07
      • 1970-01-01
      • 2020-01-21
      相关资源
      最近更新 更多