Posts

Showing posts from August, 2020

WPF and Windows Forms Data Annotations

Image
There is a lot that the .NET Framework offers and for some developers they may not find those hidden gems that others tend to find. One of these gems is data annotations which on an average web search tends to pull up ASP.NET and in some cases WPF. When a developer new to WPF finds information on data annotations and has not learned MVVM yet for whatever reasons they may not pursue this path. Similarly, the same may hold true for Windows Form developers. So for those new to WPF and those Window form developers who are open to data annotations check out the following GitHub repository .

Entity Framework Core code samples for moving away from conventional data operations

Image
Spending years in various forums answering questions what is surprising is Windows Form developers (both newcomers and season coders) are still using TableAdapter, DataAdapter or connection and command objects to interact with databases. A case may be made for each of these but they are not going to work well when considering cross platform, web solutions and in general rich user interfaces. When the chance presents itself I will suggest trying EF or EF Core and the response typically is something along the lines of "I'm just building a simple application" or similar response then sometime later that simple application has grown considerably and now warrants looking at EF or EF Core. In many cases it's too late or they just want to get the application done quickly. So over the past year I've been writing code samples to target Windows Forms developers. The downside is limited time to have a well rounded set of code samples. The goal is to start out simple with com...

Visual Studio tools for making life easier

Microsoft Visual Studio by itself it a great tool for developing applications but there are several tools to consider making development even easier. Here are my favorite extensions.  EF Core Power tools If working with Entity Framework code first consider using EF Core Power tools , with this Visual Studio extension reverse engineering  of SQL Server, Azure SQL DB, PostgreSQL, MySQL, SQLite, Oracle and SQL Server Compact databases, and SQL Server Database projects (.dacpac files) can be done by right clicking on a C# project then follow several prompts, fill out a few inputs for models and a DbContext to be generated. Download from Microsoft marketplace . DPack includes various navigation tools (aka browsers) that allow the developer to quickly find solution files, types, particular type code members, methods or properties for instance. DPack includes greatly enhanced numbered bookmarks feature, streamlined surround with feature, and much more. Two cool options, "Locate in S...

Developer and hobbyist need to learn how to debug code

One fundamental skill novice and hobbyist seems to leave learning or never learn is working with Visual Studio’s debugger. They hit code, which does not run as expected or throws a runtime exception and there is never a thought to debugging their code. Over twenty years I’ve seen developers struggle with figuring out why code is throwing exceptions or code not running as expected yet these developers refuse to learn how to debug. When appropriate when a question is asked with code not running as expected or a runtime exception is thrown, before offering suggestions ask them if they have debugged the code. If they indicate they don’t know how to debug consider sending them to the following page  and how to debug for absolute beginners to learn how to help themselves. There is really no excuse for not learning how to debug code along with when possible using Visual Studio Live Share.

Introduction to language extension method

Image
Developers are always looking for new ways to optimize their code and surprisingly extension methods are used usually when a developer doesn't realize they are using them and that they can write their own language extensions. Let's dig in. What are extension methods? Extension methods first appeared with .NET Framework 3.5 which in short allow existing classes and types to be extended. Extension methods can be very useful and make code method based, easily repeatable especially when working with many projects and have these extension methods in a class project. If you coding now with a Framework 3.5 or higher more likely than not you are using extension methods fairly often e.g. converting an array to a list via .ToList() which is a generic extension method meaning .ToList() works on strings, numerics etc. or with Entity Framework Core there is Like . When should you use extension methods? The first reason is when a developer is frequently writing custom functions that are ei...

Introducing Asynchronous coding to VB.NET novice developers

Many developers, hobbyist and weekend coders rely on searching the web for solutions to a problem rather than first reading documentation where good solutions are too abstract or in the case of Windows Forms or WPF code samples are done in a window or form. These people tend to pick the easiest solution and roll with it. A common question, how do I perform an operation and keep my application responsive? Solutions tend to range from Application.DoEvents to using a BackGroundWorker component with no mention of asynchronous solutions or an asynchronous solution is shown but like the first two are shown directly in a form. The person asking tends not to care which is better but instead which is easier to implement because to the novice coder easier is always better. If the following is shown and along with other code samples without using classes they tend not to use classes in the future. Imports  System.Threading Public   Class   Form1      Priva...

Introduction

Intent A place to find useful information on how to perform specific operations using Microsoft Visual Studio where predominate focus is on proper coding techniques along with how to articles using various programming languages Microsoft Visual Studio supports. Best practices Finding and using documentation Debugging Working with databases Using Microsoft SQL-Server coupled with Microsoft Entity Framework Core. Working with JSON, XML and NoSQL Primary programming languages C# VB.NET HTML jQuery CSS Since code samples many times are dependent on versions each article will include versions e.g. Entity Framework Core 3.5.1, C# 7.x etc. About  Karen Payne first started as a developer with Nantucket Clipper 1990, progressed to Microsoft C, Borland C, Borland Delphi and then to Microsoft Visual Studio .NET programming languages. Microsoft MVP since 2014 Authored 150 plus code articles on MSDN Authored 150 plus code articles for Microsoft TechNet Wiki Moderator on several Microsoft forum...