Form evaluation

C# coding

Asynchronous processing
LINQ and Entity Framework

SQL

UNION
HAVING

JavaScript

Return
Variable scope
Quickly chcek your knowledge in multiple topics

C# coding

Asynchronous processing

Which keyword missing in this code block?

            
        public async Task<string> GetStringFromUrl(string url)
        {
            using (var httpClient = new System.Net.Http.HttpClient())
            {
                var result = httpClient.GetStringAsync(url);
                return result;
            }
        }
            
            

Type in the missing keyword:


LINQ and Entity Framework

How many queries are executed against the database when the GetTotals method is executed?

            
        class Db
        {
            private readonly CustomerContextDb Db = new CustomerContextDb();

            private IQueryable<Customer> GetCustomers()
            {
                return Db.Customers;
            }

            private IQueryable<Sale> GetSales()
            {
                return from s in Db.Sales
                    where s.IsPaid
                    select s;
            }

            public IList<Total> GetTotals()
            {
                var totals = (
                    from s in GetSales()
                        join c in GetCustomers() on s.CustomerId equals c.CustomerId
                        group s.Amount by c into g
                        select new {
                            g.Key.CustomerId,
                            g.Key.FirstName,
                            g.Key.LastName,
                            TotalAmount = g.Sum(a => a)
                        }).ToList();
            }
        }
            
            

Select one answer:

SQL

This table data is used for both SQL queries.

TableAB:

column1
A
B
B

TableBC:

column1
B
C

UNION

How many entries will return following query?

            
        SELECT column1 FROM TableAB
        UNION
        SELECT column1 FROM TableBC
            
            

Select one option:

HAVING

How many entries will return following query?

            
        SELECT column1 FROM (
            SELECT column1 FROM TableAB
            UNION
            SELECT column1 FROM TableBC ) T
        GROUP BY column1
        HAVING count(1) = 1
            
            

Select one option:


JavaScript

Return

Consider the two functions below. Will they both return the same thing?

            
        // JavaScript source code
        function A() {
            return {
                bar: "hello"
            };
        }

        function B() {
            return
            {
                bar: "hello"
            };
        }
            
            

Select one option:


Variable scope

Which keyword is strictly prohibited in class declaration section?