SQL Interview Questions for Freshers 1. What is SQL? SQL stands for Structured Query Language. It is the primary language to interact with databases. With the help of SQL, we can extract data from a database, modify this data and also update it whenever there is a requirement. This query language is evergreen and is widely used across industries. For example, if a company has records of all the details of their employees in the database. With the help of SQL, all of this data can be queried to find out valuable insights in a short span of time. 2. How to create a table in SQL? The command to create a table in sql is extremely simple: CREATE TABLE table_name ( column1 datatype, column2 datatype, column3 datatype, .... ); We will start off by giving the keywords, CREATE TABLE, then we will give the name of the table. After that in braces, we will list out all the columns along with their datatypes. For example, if we want to create a simple employee table: CREATE TABLE ...
There could be several ways to achieve it. I'll be highlighting three different ways to achieve it First: using strongly type public static class GenericFactory { public static IGeneric < T > CreateGeneric < T >( ) { if ( typeof (T) == typeof ( string )) { return (IGeneric<T>) new GenericString(); } if ( typeof (T) == typeof ( int )) { return (IGeneric<T>) new GenericInt(); } throw new InvalidOperationException(); } } You would use it like this: var a = GenericFactory.CreateGeneric< string >(); var b = GenericFactory.CreateGeneric< int >(); Note that this uses a strongly-typed call rather than passing in the type name as a string (which may or may not be what you actually want). Second: using object If instead you want to pass a string for the type name, you will have to return an object because there is no way to return th...
In versions prior to ASP.NET MVC 3, you could not declare HTML attributes with dashes/hyphens , without creating a custom type that handled dashes for you. Most of you, who have used custom data attributes with dashes in MVC 1 and 2, must be familiar with the Compiler Error CS0746: if you use attribute name e.g "data-name", you will see an error Invalid anonymous type member declarator. Anonymous type members must be declared with a member assignment, simple name or member access However in ASP.NET MVC 3, there is a trick that can be used to handle HTML attributes with dashes. Just use ‘underscores’ in your custom data attribute instead of ‘hyphens’. MVC 3 using the HTML helpers, automatically converts these underscores into dashes/hyphens eg: @Html.HiddenFor(Model => Model.PartnerId, new { ng_model = "PartnerId" }) when view will be rendered then it'll be convert as shown below. <input type="hidden" name="PartnerId" val...
Comments
Post a Comment