Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# lightswitch中应用代码的linq查询_C#_Asp.net_Linq_Visual Studio Lightswitch_Lightswitch 2012 - Fatal编程技术网

C# lightswitch中应用代码的linq查询

C# lightswitch中应用代码的linq查询,c#,asp.net,linq,visual-studio-lightswitch,lightswitch-2012,C#,Asp.net,Linq,Visual Studio Lightswitch,Lightswitch 2012,我正在构建一个lightswitch应用程序。我有我的数据源sspData>,它有我所有的表和屏幕。现在,我正在尝试在我的应用程序中设置一个全局变量,如下所示。但是,我不能像这样查询表: this.aspnet_Users.where=>a.UserName==uName.SingleOrDefault 如何从应用程序代码中获取查询表的权限 public partial class Application { private string estateName()

我正在构建一个lightswitch应用程序。我有我的数据源sspData>,它有我所有的表和屏幕。现在,我正在尝试在我的应用程序中设置一个全局变量,如下所示。但是,我不能像这样查询表:

this.aspnet_Users.where=>a.UserName==uName.SingleOrDefault

如何从应用程序代码中获取查询表的权限

 public partial class Application
    {
        private string estateName()
        {

            string esName = "";
            string uName = this.User.Identity.Name;
            try
            {

                 **var qryUser = this.aspnet_Users.Where(a => (a.UserName == uName)).SingleOrDefault();**

                esName = qryUser.PayGroup;

            }
            catch (Exception e)
            {

                Debug.WriteLine(e.InnerException.ToString());
            }
            return esName;
        }

    }

必须将数据源作为参数传递到函数中。然后,您的表应该可以访问

您的代码应该如下所示:

public partial class Application
{
    private string estateName(sspData myDataSource)
    {

        string esName = "";
        string uName = this.User.Identity.Name;
        try
        {

             var qryUser = myDataSource.aspnet_Users.Where(a => (a.UserName == uName)).SingleOrDefault();

            esName = qryUser.PayGroup;

        }
        catch (Exception e)
        {

            Debug.WriteLine(e.InnerException.ToString());
        }
        return esName;
    }

}

这回答了你的问题吗?如果没有,请告诉我,可能还有其他事情需要做。