Getting a linq table to be dynamically sent to a method

Posted by Damian Spaulding on Stack Overflow See other posts from Stack Overflow or by Damian Spaulding
Published on 2009-06-11T01:17:23Z Indexed on 2010/06/15 20:02 UTC
Read the original article Hit count: 219

Filed under:
|

I have a procedure:

var Edit = (from R in Linq.Products
            where R.ID == RecordID
            select R).Single();

That I would like to make "Linq.Products" Dynamic. Something like:

    protected void Page_Load(object sender, EventArgs e)
    {
        something(Linq.Products);
    }
    public void something(Object MyObject)
    {
        System.Data.Linq.Table<Product> Dynamic =
            (System.Data.Linq.Table<Product>)MyObject;
        var Edit = (from R in Dynamic
                    where R.ID == RecordID
                    select R).Single();

My problem is that I my "something" method will not be able to know what table has been sent to it. so the static line: System.Data.Linq.Table Dynamic = (System.Data.Linq.Table)MyObject;

Would have to reflect somthing like: System.Data.Linq.Table Dynamic = (System.Data.Linq.Table)MyObject;

With being a dynamic catch all variable so that Linq can just execute the code just like I hand coded it statically. I have been pulling my hair out with this one. Please help.

© Stack Overflow or respective owner

Related posts about linq-to-sql

Related posts about dynamic