Posts

Showing posts from September, 2016

C#: What is the difference between IQueryable vs IEnumerable?

The main difference between the two is the location of the query execution. The following example demonstrates the difference: IQueryable<Model> models = ... models.Where(x => x.ID ...) IQueryable is used from LINQ-to-Anything (such as SQL). In this case, the query filter will be executed on the SQL server. This is great for reducing the amount of data returned from the data store. However, if the code looks as follows: IEnumerable<Model> models = ... models.Where(x=> x.ID ...) The results might be the same but using IEnumerable will cause the query results to be loaded in the memory and the predicate will be executed on the entire result set.

C#: How can I get my Selemium test to log into Azure?

I have been writing some entry level Selenium tests for my Azure website that authenticates using Azure AD. The biggest issue is trying to get the WebDriver to authenticate into the solution. After a lot of learning (read: failed attempts) I have the following solution (read: hack) that seems to work. 1. In my [TestInitialize] method, I load JQuery to the created page public static class Common     {         public static string GetEval(IWebDriver driver, string script)         {             IJavaScriptExecutor js = driver as IJavaScriptExecutor;             return (string)js.ExecuteScript(script);         }         public static string GetFile(string path)         {             using (var reader = new StreamReader(path))             {                 return reader.ReadToEnd();             }         } } Common.GetEval(driver, Common.GetFile("Lib\\jquery.js")); NOTE: I created a folder called 'lib' and added the jquery.js file. Most importantly

CSS: How do I create a single 'back to top' button?

A little CSS and JQuery can produce a lot of magic in an application. Here is the code. 1. Start with a simple html page. The important item here is to have an 'ID' to navigate to. In my case, I called it 'top'. <html> <head>     <base href="/" />     <title>Test Page</title>     <meta charset="UTF-8" />     <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">     <meta name="viewport" content="width=device-width, initial-scale=1.0">     <script src=”//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js”></script>     <link href="css/myStuff.css" rel="stylesheet" /> </head> <body>     <div>         <!-- Start Body Content -->         <div ng-view role="main" id="top"></div>         <!-- End Body Content -->     </div> <

SharePoint: Cannot file "Style%2520Library/Js/myfile.js"

I recent SharePoint deployment raised the interesting error about a missing file. When I checked the expected folder, the file was there so the error seemed a little strange. The solution is in the message: The missing file is Style %2520 Library. The cause was an incorrect link reference in the masterpage. The link was set to <SharePoint:ScriptLink Name="~SiteCollection/ Style%20Library /JS/myfile.js" runat="server" ID="ScriptLink2" /> SharePoint is url encoding the value. The encoded value of '%' is '%25', which results in the strange url. I removed the %20 from the link address and the issue was resolved.