1

I am building a lightswitch application. I have my DataSource (sspData > which has all my tables) and my screens. Now I am trying to set a global variable in my Application as shown below. However I can't just query the tables just like:

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

How do I get "access" to query the table from within my application code?

 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;
        }

    }
TsSkTo
  • 1,412
  • 13
  • 25
Maverick1415
  • 113
  • 1
  • 12
  • Has this answered your question? If not, let me know, there may be something else that has to be done. – TsSkTo Nov 28 '13 at 14:13

1 Answers1

0

You have to pass your data source as a parameter into your function. Your tables should then be accessible.

Your code should look like this:

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;
    }

}
TsSkTo
  • 1,412
  • 13
  • 25