Skip to main content

Posts

Scaffold Existing SQL Database Using Entity Framework Core

Introduction. There are many data access technique and tools out there that allow our application  interact with our data store, things like AutoMapper, Dapper and many more. In this article we are making use of Entity Framework Core to create our database context for communicating with our data store ( in this case SQL RDBMS ). Assumptions This article assume that we are going to perform data access for an ASP.Net Core application. All crosscutting concern will be ignored Consideration The code involved in this article is based on assumptions, It was proposed for the intention to show its functions/features based on the article title. For production/release we might need to tweak it to meet the company policy, best practice and industry standards. The code/script snippet is free to use anywhere. The Requirement Statement We are required to create a data access library that will be consumed by a client ( Asp.Net Core ) . This library then will be referenced by the client to

C# - Using Named Tuples As 'Object On The Fly'

Introduction As the date of today, we have seen various evolution of C# in many ways, In this article we are going to discuss on the new features release in C#7.0 called Named Tuples , Throughout our experience in making use of the normal tuples, we usually instantiate an instance of a tuple and then we may get the assigned values with something like 'Item1' , 'Item2'. Now, they have come up with some 'sugar' by enabling us to assign it a name, I personally think that this features really help us as a developer to understand our code more easily. This somehow portray that C# is becoming more dynamic towards its programming pattern. Note than the title 'Object On The Fly' is somehow a sugar of my own, and not related to any programming technique or any design patterns. But i am pretty sure that we might going to encounter it a lot in the future. Consideration The code involved in this article is based on assumptions, It was proposed for the intenti

AppCenter - Crashlog Sink Using AppCenter

Introduction Appcenter is a Microsoft features product that helps developers/testers/maintainers manage our apps that has been published to the wild. Previously it was known as HockeyApp. In this article, we are going to discuss on how to strategize/handle/manage our crash report mechanism. Since our solution policies may varies between countries, this article will somehow propose a design technique on how to organize our app crash report that is used based on country. Consideration This code base is proposed for the intention of specific problem domain that we might encounter throughout our development lifecycle, for production/release we might need to tweak it to meet the company policy, best practice and industry standards. The code snippet is free to use anywhere. The Assumption Assuming we are dealing with a lot of phases in our development life cycle, Things like a blue green deployment, Development phase, Testing, and even production-live solutions. It is always nice to

C# - Fine Tuning Your Processor/IO Load With SemaphoreSlim

Introduction It is very important to predict the behavior of our system at the early stage of our development, Things like understanding the potential user loads, migration strategy, security routine and many more, these activity will consume system resources and without proper planning design, it might impact the performance/delivery of our system. In this article we will discuss on how to limit our solution tasks ( usually long running large processing task ) using SemaphoreSlim , SemaphoreSlim will limit a task from running concurrently based on a given number, with these limitation, we will somehow reduce the possibility that some tasks that consuming large resources will not bring a huge impact to other small processing tasks from doing its job. The Problem Statement Assuming we are using some sort of custom encryption to store our data at a data store, take an example a NoSQL database, we don't want the data that live in the data store to be in plain text ( due to comp

Legacy - Asp.Net Web Form - Tracing Your Web Page Performance

Introduction Asp.Net Web Forms, can be considered as a legacy technology, but somehow it is still widely used in the industry ( as for today date 2018 ). In this article, we will discuss on how to perform web page Tracing , a technique that will help us analyze our front end performance, It is very useful in collecting end-user data analytics. This article will become handy if we need to work our way out with working/maintaining/enhancing our complex legacy systems Consideration It is advised to perform such task at a staging/development environment. As tracing will reveal some sensitive information about our system How To Trace Your Site There are 3 different ways to perform Web Page Tracing 1. From Code Behind - Is preferred when we experience working with the source code. 2. From The ASPX page - If you have a compiled solution by your developers, and you wanted to perform the performance analysis details by tweaking the ASPX page. 3. From The Web.Config File - Please t

WebAPI - Custom Routing With RoutePrefixAttribute

Web Api is a good platform to assists in data access strategy for mobile solutions or n-tier architecture. Problem always arise when we need to customize our demanding clients caller. With regards our client needs, we may take advantage of RoutePrefixAttribute to perform the task. This is by making use of the routing customization that Web API has to offer. The client may adjust their needs based on their Uri and make a call . The Requirements 1. We have IOs clients that require Json data, despite there are many versions, each version return different set of data. 2. We also have an Application that is very customized that require a custom XML schema data type and have many version that are calling from RedHat server. This article will make use of RoutePrefixAttribute to solve the requirements. Yes, there are many other way to solve and meet the requirements, this solution might be a suitable choice and show the capability of Web API 2. Note that all the customized requirem

Legacy - Asp.Net Web Form - User Control - Create One

Asp.Net Web Forms, can be considered as a legacy technology, but somehow it is still widely used in the industry ( as for today date 2018 ). Here is where we may find an article about creating a User Control that is useful for guidance if we encounter such solution. Adding a new user control Example . 1. Add new user control 2. Add Child Control 3. Add Desired Code behind algorithm 4. Drag user control from solution explorer to desired web page . 5. Baam .. now the user control is there . Consideration 1. Accessing the properties . - Add a public properties on the user control code behind . And Assign desired task on page_load . Example : We may use it like this too Published on : 27-Dec-2018 Legacy Published on : 17-Dec-2014 Ref no : DDN-L-WPUB-00001 About Author Wan Mohd Adzha MCPD,MCSD,MCSE I am passionate about technology and of course love Durians. Certified by Microsoft as MCP Since 2011. Blogging from Malaysia

C# - Mining Object Model Data For The Sake Of TroubleShooting.

The Problem Statement It is always challenging to debug our solution when we try to reproduce a certain bug/issue, It often easy to debug when it happen at a developer/programmer own dev machine, but things get really hard when the bug/issue happened at clients device or remote server. Using try/catch exception will help us on showing some hint on where the bug happen or what action actually violate our requirement. But it wont actually help us on trying to reproduce the bug, This is often due to the current state of the system and probably the object state that doesn't meet the requirement. Consideration This code base is proposed for the intention of specific problem domain that we might encounter throughout our development lifecycle, for production/release we might need to tweak it to meet the company policy, best practice and industry standards. The code snippet is free to use anywhere. The Requirement To help assist developer/programmer in trying to reproduce a speci

Azure Table Storage - Create/Update

The Requirement Assuming that we have a front end solution and we are going to create a lightweight CMS for its landing page, The landing page has a splash carousel banner that switch between banner automatically, Our mission is to populate the banner list to the front end hooked with Javascript framework and css that is already downloaded to the client browser / Apps. Our CMS team require some sort like a mechanism to publish new banner or delete old banner or take a specific banner online during festive season or offline when it is over. We decided to use Azure Table Storage as our data store and currently developing the data access strategy. Consideration This code base is proposed for the intention for understanding its usage, for production/release we might need to tweak it to meet the company policy, best practice and industry standards. The Model We are using an interface to describe our concrete data model entity The Table Entity In order to use Azure Table Storage

WebAPI - Custom Attribute Routing - Intermediate

Assuming that there are 100 method in our controller that need to be routed properly. Implementing the previous technique might be risky, as it will introduce bug due to human error and hard for new developer to understand. In the industry this will impact the team performance and efficiency. Luckily Web API 2 have a workaround to make our code more elegant and bug risk free by implementing Custom Attribute Routing Constraint . This article will explain the basic step to produce Custom Attribute Routing Constraint components, configurations and implementations. The step to produce it is as below 1.Create the Attribute Routing Constraint Component By Implementing IHttpRouteConstraint Interface 2. Register the Attribute Route Constraint To The WebApiConfig config.MapHttpAttributeRoutes(customattribute) 3.Decorate the desired method with the Custom Routing Constraint Attribute in the controller. The Requirements There is too many methods in our controller, routing

WebAPI - Attribute Routing Based On Parameter Type - Basic

There will come into a certain situation where we might encounter parameter issue when implementing Web Api methods in a specific controller. This is usually happen when we wanted to make use of an overloaded technique in our Web Api methods. For example Notice that the method name is the same but the method is able to compile since its an overloaded method. The problem arise when the code is deployed and being called by clients . Below are the call that will return with error. Request GET http://localhost:48795/api/backendata/678 HTTP/1.1 Response HTTP/1.1 400 Bad Request ...... Next we are trying to hit the second method by sending a parameter with a string type. Request GET http://localhost:48795/api/backendata/foo HTTP/1.1 Response HTTP/1.1 400 Bad Request ...... This is due to the fact that there is a conflict for the engine to determine to use parameter as an int or a string, the code will raise an exception that return a bad request response. Luckily Asp.Ne

WebAPI - Simple-Attribute-Routing - Basic

Attribute routing is very helpful when you are trying to customize the response behavior of your RESTful application. For this article example, we will take advantage of the Attribute Routing by performing some filtering at the back end by decorating the method in the controller. Below are the code to show the implementation. Notice the route attribute is different for each method. Not just to route attribute is different, we also may pick any arbitrary method name that is following naming convention in our development environment. Take note for this example, we make use of Authorization attribute. Based on the code, we may now able to give the caller some options on how the response going to be. Assuming the caller is a Manager, which hold the role for HR and Sales. The caller (manager) will be able to make use of the Attribute Routing to pick which response he/she would prefer.If he/she would like to : 1.Get all public data - The Manager may call http://localhost:26374/ap