none
how to make LINQ to SQL result become a global variable RRS feed

  • Question

  • public partial class Form1 : Form 
        { 
            public Form1() 
            { 
                InitializeComponent();     
            } 
            private void button1_Click(object sender, EventArgs e) 
            { 
                Common.NorwindDataContext context = new NorwindDataContext();      
                var results = context.Suppliers.GroupJoin(context.Products, c => c.SupplierID, d => d.SupplierID, (a, b) => new { supplier = a.CompanyName, products = b }); 
            } 
        }


    results is a local variable, but now, i want it become a global variable, please help me.
    thank for help

    Wednesday, March 25, 2009 1:11 PM

All replies

  • If your new results will be of same type then you may make a class comprising of Supplier and Products as it's member and use its object globally.
    Thursday, October 13, 2011 4:40 AM
  • If you're developing in Framework 4 then you got a type "dynamic" you can use it to store any value or Object in it.

    else you can defile a list of Objects, May be the class's structure would looks like..

    Hope this helps...!


    With Best Regards, Boovendan M
    • Proposed as answer by BoovendanM Wednesday, February 6, 2013 7:35 AM
    Thursday, October 13, 2011 2:16 PM
  • Is your problem solved Mr. Hai Dang ?

    With Best Regards, Boovendan M

    Wednesday, February 6, 2013 7:35 AM