ewbi

decades of business solution development
info@ewbi.com

gists

ASP.NET Model Binding an Odd Dictionary Array

The Kendo UI DataSource uses JQuery's unique $.param serialization style for its server-side sorting query string parameter, which on the surface doesn't seem to lend itself to deserialization by the standard ASP.NET model binder. It looks like this:

sort[0][field]=FieldName1&sort[0][dir]=asc&sort[1][field]=FieldName2&sort[1][dir]=desc

However, it turns out it can be deserialized into an array of two-element Dictionaries:

public Dictionary<string, string>[] Sort { get; set; } = [];

Each resulting Sort Dictionary will contain two elements, with the keys "field" and "dir".

Excel Formula Parsing

Nearly twenty years ago I cranked out some JavaScript that parsed Excel formulas into their constituent tokens based on some simple syntactic rules without needing a full BNF grammer or even a complete list of Excel functions and parameters. I attached that code to a text input field in a post on the old ewbi.develops blog (now long gone) and it became quite popular. I later implemented similar logic in a C# library and used it for a client project for bulk evaluation of thousands of Excel workbooks. The JavaScript and C# sampler were free to use, and given a legitimate MIT license in 2016, so others picked it up and implemented it in still more languages. All these years later I still get inquiries about that logic, and there are numerous references to the original blog post and its follow-ups scattered around the web, so I thought I might save everyone some time by rolling up the relevant links here.

My Code

Other Languages

Beware Graph SearchRequest re-use when sorting

There aren't many examples of how to use the Graph SDK for .NET to perform Graph search/query API calls, and even fewer showing how to "page" through the sets of hits it returns. In short, the SearchRequest includes From and Size properties, the former generally starting at 0 and the latter (per Microsoft's recommendation) starting with a small number like 25. The QueryPostResponse returns a hit count, and indication of whether there are more hits available, and a Value property with a collection of SearchResponse items. In most examples found on the webs, "paging" amounts to enumerating the hits in the response and if there are more hits available, then bumping the SearchRequest From by the Size (and then generally increasing Size, like to 200), posting the request again, and repeating until there are no more hits. This differs considerably from the other Graph collection results, which rely on a special PageIterator to walk the @odata.nextLink URLs found in the responses. In this case, there's no connection, no "next" URL, between calls, each call is independent. And this works fine until you add a sort via the SearchRequest SortProperties. When sorted, the SearchRequest (or perhaps the QueryPostRequestBody that it's enveloped in, I never could find the link) winds up with some state that results in an unhelpful "The call failed, please try again." exception if it's posted again with different From/Size properties. So, create a new one each time. And be prepared to deal with duplicates, because even with trimDuplicates there's no guarantee that the search index won't change between calls.

Mysterious domain cookie disappearance

techs

  • .NET (C#/VB.NET; Framework/Core)
  • ASP.NET (MVC/Razor/Web API; Classic ASP)
  • WinForms/XAML
  • Office (VSTO/web add-ins)
  • SharePoint (Graph SDK/PnP)
  • Sitefinity (CMS)
  • JavaScript/JSON
  • SQL Server
  • SQLite
  • PostgreSQL
  • Entity Framework/ADO.NET
  • PICK/OpenInsight
  • ODBC/OLEDB/ADO
  • XML/XSLT

gigs

  • 1693 Analytics, LLC
  • Academy for Educational Development
  • Accessible Media Inc. (via Cypress Consulting)
  • AgilQuest
  • American National Can
  • American Nurses Association
  • Business Valuation Resources
  • CMG Health
  • Continental Computers, Inc.
  • Council of Fleet Specialists
  • DRT Systems International
  • Kansas Dairy Ingredients
  • Marsh & McLennan Companies
  • Mercer Delta Organizational Consulting
  • Mercer Human Resource Consulting
  • National Information Clearinghouse for Children with Disabilities
  • Northstar Consultants
  • Russell Investments (via Cypress Consulting)
  • Scientific Ecology Group
  • Udea Life
  • United Federation of Doll Clubs
  • VMG Healthcare Consultants
  • Washington, DC Office of Zoning