<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://community.entityspaces.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>General</title><link>http://community.entityspaces.net/forums/45.aspx</link><description>Check sub-forums before you post here</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP1 (Build: 31031.3054)</generator><item><title>Re: Collection re-query the last query result</title><link>http://community.entityspaces.net/forums/thread/16474.aspx</link><pubDate>Sat, 24 Oct 2009 02:19:49 GMT</pubDate><guid isPermaLink="false">fc29756b-907a-45c7-bf99-e939cf2d0092:16474</guid><dc:creator>howcool</dc:creator><slash:comments>0</slash:comments><comments>http://community.entityspaces.net/forums/thread/16474.aspx</comments><wfw:commentRss>http://community.entityspaces.net/forums/commentrss.aspx?SectionID=45&amp;PostID=16474</wfw:commentRss><description>&lt;P&gt;Thanks for your help. It works as expected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;What I want accomplish to&amp;nbsp;hit for the database again when the criteria for conditions was met, that's why I re-query the database under certain circumstances. If in standalone application, it was not a problem. When it involves concurrent users using the application, this would be an issue for us since some users may see other user changes result and some didn't since it was loaded before user make changes or adding new records. Althrough it was an expensive call to hit the database, but it reduces the issues for incident.&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>Re: Collection re-query the last query result</title><link>http://community.entityspaces.net/forums/thread/16470.aspx</link><pubDate>Fri, 23 Oct 2009 15:04:23 GMT</pubDate><guid isPermaLink="false">fc29756b-907a-45c7-bf99-e939cf2d0092:16470</guid><dc:creator>David.Parsons</dc:creator><slash:comments>0</slash:comments><comments>http://community.entityspaces.net/forums/thread/16470.aspx</comments><wfw:commentRss>http://community.entityspaces.net/forums/commentrss.aspx?SectionID=45&amp;PostID=16470</wfw:commentRss><description>&lt;P&gt;In addition to using coll.Query.Load rather than coll.LoadAll as Mike pointed out, I think you need to test the checked/unchecked status of a radio button inside your CheckChanged events.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;The user checks radiobutton 1 and that event fires and loads the query.&lt;/LI&gt;
&lt;LI&gt;The user then checks radiobutton 2 and that event fires. But, the user action also un-checks radiobutton 1 so that event fires as well because it changed. You need to know what it changed to before you load. &lt;/LI&gt;&lt;BR&gt;
&lt;DIV class=code&gt;
&lt;H6&gt;Code:&lt;/H6&gt;&lt;PRE class=coloredcode&gt;&lt;SPAN class=kwd&gt;private void&lt;/SPAN&gt; radioButton1_CheckedChanged(&lt;SPAN class=kwd&gt;object&lt;/SPAN&gt; sender, EventArgs e)
{
    &lt;SPAN class=kwd&gt;if&lt;/SPAN&gt; (radioButton1.Checked)
    {
        CustomerCollection col = &lt;SPAN class=kwd&gt;new&lt;/SPAN&gt; CustomerCollection();
        col.Query.Where(col.Query.LastName == &lt;SPAN class=st&gt;"A"&lt;/SPAN&gt;);
        col.Query.Load();
    }
}&lt;/PRE&gt;&lt;/DIV&gt;&lt;/UL&gt;
&lt;P&gt;I have an additional question, though. You have already loaded all columns for all rows in your Form1_Load event. Why hit the database again as the user filters data with the RadioButtons? Can't you filter the already in-memory collection instead?&lt;/P&gt;
&lt;P&gt;
&lt;DIV class=code&gt;
&lt;H6&gt;Code:&lt;/H6&gt;&lt;PRE class=coloredcode&gt;&lt;SPAN class=kwd&gt;private void&lt;/SPAN&gt; radioButton1_CheckedChanged(&lt;SPAN class=kwd&gt;object&lt;/SPAN&gt; sender, EventArgs e)
{
    &lt;SPAN class=kwd&gt;if&lt;/SPAN&gt; (radioButton1.Checked)
    {
        col.filter = &lt;SPAN class=st&gt;"[LastName] = 'A'"&lt;/SPAN&gt;;
    }
}

&lt;SPAN class=kwd&gt;private void&lt;/SPAN&gt; radioButton2_CheckedChanged(&lt;SPAN class=kwd&gt;object&lt;/SPAN&gt; sender, EventArgs e)
{
    &lt;SPAN class=kwd&gt;if&lt;/SPAN&gt; (radioButton2.Checked)
    {
        col.filter = &lt;SPAN class=st&gt;"[LastName] = 'B'"&lt;/SPAN&gt;;
    }
}

etc.&lt;/PRE&gt;&lt;/DIV&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>Re: Collection re-query the last query result</title><link>http://community.entityspaces.net/forums/thread/16468.aspx</link><pubDate>Fri, 23 Oct 2009 15:00:55 GMT</pubDate><guid isPermaLink="false">fc29756b-907a-45c7-bf99-e939cf2d0092:16468</guid><dc:creator>howcool</dc:creator><slash:comments>0</slash:comments><comments>http://community.entityspaces.net/forums/thread/16468.aspx</comments><wfw:commentRss>http://community.entityspaces.net/forums/commentrss.aspx?SectionID=45&amp;PostID=16468</wfw:commentRss><description>I even try out the code, but it still send 2 queries at SQL Profiler. 1st query show Last query string and send to SQL server, and 2nd query is the query result i want to achieve and retrieve the data that I want. Any idea how to prevent 1st query send to the SQL server? You can even try out the scenario as I illustrate before, then using&amp;nbsp;SQL profiler to trace it.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>Re: Collection re-query the last query result</title><link>http://community.entityspaces.net/forums/thread/16463.aspx</link><pubDate>Fri, 23 Oct 2009 11:32:00 GMT</pubDate><guid isPermaLink="false">fc29756b-907a-45c7-bf99-e939cf2d0092:16463</guid><dc:creator>Scott.Schecter</dc:creator><slash:comments>0</slash:comments><comments>http://community.entityspaces.net/forums/thread/16463.aspx</comments><wfw:commentRss>http://community.entityspaces.net/forums/commentrss.aspx?SectionID=45&amp;PostID=16463</wfw:commentRss><description>LastQuery is for viewing the emitted SQL from a dynamic query, not loading it.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>Re: Collection re-query the last query result</title><link>http://community.entityspaces.net/forums/thread/16461.aspx</link><pubDate>Fri, 23 Oct 2009 11:27:43 GMT</pubDate><guid isPermaLink="false">fc29756b-907a-45c7-bf99-e939cf2d0092:16461</guid><dc:creator>Mike.Griffin</dc:creator><slash:comments>0</slash:comments><comments>http://community.entityspaces.net/forums/thread/16461.aspx</comments><wfw:commentRss>http://community.entityspaces.net/forums/commentrss.aspx?SectionID=45&amp;PostID=16461</wfw:commentRss><description>&lt;P&gt;The code is incorrect, you're not even executing the queries&amp;nbsp;...&lt;/P&gt;
&lt;P&gt;This&lt;/P&gt;
&lt;DIV class=code&gt;
&lt;H6&gt;Code:&lt;/H6&gt;&lt;PRE class=coloredcode&gt;&lt;SPAN class=kwd&gt;private void&lt;/SPAN&gt; radioButton1_CheckedChanged(&lt;SPAN class=kwd&gt;object&lt;/SPAN&gt; sender, EventArgs e)
{
    CustomerCollection col = &lt;SPAN class=kwd&gt;new&lt;/SPAN&gt; CustomerCollection();
    col.Query.Where(col.Query.LastName == &lt;SPAN class=st&gt;"A"&lt;/SPAN&gt;);
    col.LoadAll();
}
&lt;/PRE&gt;&lt;/DIV&gt;&amp;nbsp; 
&lt;P&gt;Should be (notice the way we load it ...)&lt;/P&gt;
&lt;P&gt;
&lt;DIV class=code&gt;
&lt;H6&gt;Code:&lt;/H6&gt;&lt;PRE class=coloredcode&gt;&lt;SPAN class=kwd&gt;private void&lt;/SPAN&gt; radioButton1_CheckedChanged(&lt;SPAN class=kwd&gt;object&lt;/SPAN&gt; sender, EventArgs e)
{
    CustomerCollection col = &lt;SPAN class=kwd&gt;new&lt;/SPAN&gt; CustomerCollection();
    col.Query.Where(col.Query.LastName == &lt;SPAN class=st&gt;"A"&lt;/SPAN&gt;);
    col.Query.Load();
}
&lt;/PRE&gt;&lt;/DIV&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>Collection re-query the last query result</title><link>http://community.entityspaces.net/forums/thread/16459.aspx</link><pubDate>Fri, 23 Oct 2009 11:06:26 GMT</pubDate><guid isPermaLink="false">fc29756b-907a-45c7-bf99-e939cf2d0092:16459</guid><dc:creator>howcool</dc:creator><slash:comments>0</slash:comments><comments>http://community.entityspaces.net/forums/thread/16459.aspx</comments><wfw:commentRss>http://community.entityspaces.net/forums/commentrss.aspx?SectionID=45&amp;PostID=16459</wfw:commentRss><description>&lt;P&gt;I have a group box with a few radioboxes. My SQL&amp;nbsp;query will be based on radiobox checked status. I have found that the collection will send last query to SQL server once before new query execute it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;For example, in form load event and radiobox checked event&lt;/P&gt;
&lt;DIV class=code&gt;
&lt;H6&gt;Code:&lt;/H6&gt;&lt;PRE class=coloredcode&gt;&lt;SPAN class=kwd&gt;private void&lt;/SPAN&gt; Form1_Load(&lt;SPAN class=kwd&gt;object&lt;/SPAN&gt; sender, EventArgs e)
{
            CustomerCollection col = &lt;SPAN class=kwd&gt;new&lt;/SPAN&gt; CustomerCollection();
            col.LoadAll();
}

&lt;SPAN class=kwd&gt;private void&lt;/SPAN&gt; radioButton1_CheckedChanged(&lt;SPAN class=kwd&gt;object&lt;/SPAN&gt; sender, EventArgs e)
{
            CustomerCollection col = &lt;SPAN class=kwd&gt;new&lt;/SPAN&gt; CustomerCollection();
            col.Query.Where(col.Query.LastName == &lt;SPAN class=st&gt;"A"&lt;/SPAN&gt;);&lt;BR&gt;            col.LoadAll();
}

&lt;SPAN class=kwd&gt;private void&lt;/SPAN&gt; radioButton2_CheckedChanged(&lt;SPAN class=kwd&gt;object&lt;/SPAN&gt; sender, EventArgs e)
{
            CustomerCollection col = &lt;SPAN class=kwd&gt;new&lt;/SPAN&gt; CustomerCollection();
            col.Query.Where(col.Query.LastName == &lt;SPAN class=st&gt;"B"&lt;/SPAN&gt;);&lt;BR&gt;            col.LoadAll();
}

&lt;SPAN class=kwd&gt;private void&lt;/SPAN&gt; radioButton3_CheckedChanged(&lt;SPAN class=kwd&gt;object&lt;/SPAN&gt; sender, EventArgs e)
{
            CustomerCollection col = &lt;SPAN class=kwd&gt;new&lt;/SPAN&gt; CustomerCollection();
            col.Query.Where(col.Query.LastName == &lt;SPAN class=st&gt;"C"&lt;/SPAN&gt;);&lt;BR&gt;            col.LoadAll();
}&lt;/PRE&gt;&lt;PRE class=coloredcode&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE class=coloredcode&gt;When form executed, it will run the following SQL at SQL Profiler&lt;/PRE&gt;&lt;PRE class=coloredcode&gt;&lt;DIV class=code&gt;&lt;H6&gt;Code:&lt;/H6&gt;&lt;PRE class=coloredcode&gt;SELECT * FROM Customer&lt;/PRE&gt;&lt;/DIV&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE class=coloredcode&gt;When I checked radiobox2, it will execute 2 query at SQL Profiler&lt;/PRE&gt;&lt;PRE class=coloredcode&gt;&lt;DIV class=code&gt;&lt;H6&gt;Code:&lt;/H6&gt;&lt;PRE class=coloredcode&gt;Query 1

SELECT * FROM Customer

Query 2

SELECT * FROM Customer Where LastName=&lt;SPAN class=st&gt;'B'&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE class=coloredcode&gt;When I try to checked radiobox3, it will also send last query to SQL Profiler&lt;/PRE&gt;&lt;PRE class=coloredcode&gt;&lt;DIV class=code&gt;&lt;H6&gt;Code:&lt;/H6&gt;&lt;PRE class=coloredcode&gt;Query 1
SELECT * FROM Customer Where LastName=&lt;SPAN class=st&gt;'B'&lt;/SPAN&gt;

Query 2
SELECT * FROM Customer Where LastName=&lt;SPAN class=st&gt;'C'&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE class=coloredcode&gt;I feel very curious on it. Althrough last query will not populate data into the collection, and&lt;BR&gt;it will populate data using new query result into collection, but is it this situation is normal&lt;BR&gt;or any issue to the ES?&lt;/PRE&gt;&lt;PRE class=coloredcode&gt;Version: 2009.2.1012.0&lt;/PRE&gt;&lt;/DIV&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>