Use a numeric suffix to explicitly declare a numeric literal to be of a specific numeric type (U for unsigned int, L for long, UL for unsigned long, M for decimal, F for float, and D for double).
Use verbatim string (prefixed with the @ character) if you don’t want the characters in your string translated (e.g. if you have escape sequences, etc.), except for the double quote escape sequence, as in below:
Use null coalescing (??) if the variable you are working on can be null and you don’t want null.
Use | or & if you are not short-circuiting, otherwise use || or &&.
There are actually 4 types of main entry point in a C# program. They are:
There is no cascading of case in switch which is why each case including the default need to have the break. But you can cascade cases that have no statements, as in below. Useful when you need to handle multiple cases in the same way.
As promised in my previous post, I will look briefly into ways on how to architect multi-tenant data. Multi-tenant means servicing multiple clients or tenants. In the case of a data architecture, it’s how to store data from multiple clients. I learned there are three options to do this, not just two. I know the two of them are the most common which I will talk first.
First option, is using Separate Databases. This is the simplest approach of all the three. Basically each client has its own copy of the database, and sometimes depending on the client’s strict security requirements, can be located on a server separate from the others. It may be inexpensive in terms of development cost to do this way initially, but in the long run, it will be more expensive in terms of operational cost.
Second option, is using Shared Database and Shared Schema. Only one database and one set of tables are used to store all the clients’ data. The only thing that differentiates them from each other is an ID unique to each client. In contrast to using separate databases, using shared database and shared schema has a higher development cost but a lower operational cost.
These two options are popular, at least in my experience. They are actually mostly used by application service provider companies. In my last company, they use the separate databases option. The company before that, I know they used the shared database and shared schema option. Little did I know that there is a third option, which I still have yet to see implemented in an ASP company.
So the third option, is using Shared Database and Separate Schemas. What this means is that there is only database but each client has its own copy of the set of tables that are grouped into a schema unique to each client. So basically, when onboarding a new client, a schema unique to the client is created first and assigned and defaulted to the client account. From within that client’s schema, you then create the tables with the schema name as the qualifier for naming the tables to be created. When accessing the client’s data, since the client’s default schema is set, you don’t have to qualify the table names with the client’s schema name. Therefore, you use the same SQL statements for all clients. There is no duplication of SQL statements here.
These three options have their own pros and cons which I won’t be talking here. This is just to give an idea what these options are. If you need more information, check this link.
I have been asked a couple of times in my job interviews about GET, POST, IsPostBack, QueryString, and Forms. These are the basics that one who has worked on ASP.NET should know. Sometimes you get focused on higher level stuff especially if you are working with wrappers or some sort of framework on top of ASP.NET that you lose focus on the basics. It happens. At least to me it happens.
So what is GET? GET is one of the most common HTTP commands, just like POST, that is sent by the browser to the web server. It tells the web server to get or fetch a page for the browser. So when you type a URL
on your browser’s address window and press ENTER, the browser sends a GET command to the web server and the web server fetches the page and sends it back to the browser and the browser displays the page. Simple.
POST, on the other hand, is sent by the browser to the web server if it needs to post or send back data or information to the web server. So when you fill up information on a web page, say maybe you are creating a new user account, and pressed a submit button, the browser sends a POST command, attaches the information you entered and sends it to the web server.
IsPostBack is a property of the Page class representing a Web Forms page in ASP.NET. You use this property to check if the page is being loaded or rendered or being requested for the first time (a GET command) as opposed to being loaded as a response to a postback (a POST command).
Querystring is the string you see in a URL after the ? character
It allows you to pass data from one page to another. It can contain more than one name/value pair
separated by the & character. On the target page (e.g. results.aspx) one can access the name/value pair using the QueryString collection of the Request object
Form collection is another property of the Request object that allows you to access the information sent by the browser through a POST command. It retrieves the values of the form elements. So if we have the following form tag:
we can retrieve the customer ID using the following code: