Ejemplo n.º 1
0
        protected void RunButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (SessionManager.Instance.CurrentIndex == null)
                {
                    return;
                }

                CodeGenerator generator = new CodeGenerator();
                string        code      = generator.GetLinqCode(GetObjectType(), GetWhereClause(), GetTakeClause());
                var           result    = Compiler.CompileAndRun(code, GetSearchResultItemAssembly());
                int           timeTaken;
                if (!Int32.TryParse(result.Item1, out timeTaken))
                {
                    ErrorLabel.Text = result.Item1;
                }
                else
                {
                    ErrorLabel.Text = String.Empty;
                    //Unfortunately we can't really work on the entered searchResultClass type as it can't be passed to T
                    IEnumerable <SearchResultItem>      results    = result.Item2.Select(i => i as SearchResultItem);
                    LinqSearchResult <SearchResultItem> resultList = new LinqSearchResult <SearchResultItem>(results);
                    SessionManager.Instance.LinqSearchResults = resultList;
                    int numberOfHits = results.Count();
                    TotalHitsLabel.Text   = numberOfHits.ToString();
                    TimeElapsedLabel.Text = result.Item1 + "ms";
                }
            }
            catch (Exception ex)
            {
                ErrorResolver.ResolveError(ex, this);
            }
        }
Ejemplo n.º 2
0
        protected void RunButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (SessionManager.Instance.CurrentIndex == null)
                    return;

                CodeGenerator generator = new CodeGenerator();
                string code = generator.GetLinqCode(GetObjectType(), GetWhereClause(), GetTakeClause());
                var result = Compiler.CompileAndRun(code, GetSearchResultItemAssembly());
                int timeTaken;
                if (!Int32.TryParse(result.Item1, out timeTaken))
                {
                    ErrorLabel.Text = result.Item1;
                }
                else
                {
                    ErrorLabel.Text = String.Empty;
                    //Unfortunately we can't really work on the entered searchResultClass type as it can't be passed to T
                    IEnumerable<SearchResultItem> results = result.Item2.Select(i => i as SearchResultItem);
                    LinqSearchResult<SearchResultItem> resultList = new LinqSearchResult<SearchResultItem>(results);
                    SessionManager.Instance.LinqSearchResults = resultList;
                    int numberOfHits = results.Count();
                    TotalHitsLabel.Text = numberOfHits.ToString();
                    TimeElapsedLabel.Text = result.Item1 + "ms";
                }
            }
            catch (Exception ex)
            {
                ErrorResolver.ResolveError(ex, this);
            }
        }