subsonic

How to perform a table UNION in SubSonic


I have a query that performs a UNION between two tables. I'm trying to implement the same thing with SubSonic. I have two related questions:


Solution

  • There isn't a UNION syntax in SubSonic. You could use an inline query as dicussed here e.g.

    MyTableCollection MyTable = new InlineQuery().ExecuteAsCollection<MyTableCollection>(
        “SELECT Col1,Col2 FROM TableA Union SELECT Col1,Col2 FROM TableB");
    

    The best solution I've found is to implement the UNION inside a view and then get SubSonic to generate a model for that view instead.