Difference between Varchar and Nvarchar. When to use what?

To order essay on an author of the essay not only that but safely. Our exchange provides a number of obligations, which guarantee customers that they will receive a high quality and decent work:

each essay is checked by the system Antiplagiat, which ensure that the text was unique;

you made your payment remains “frozen” for the author until the time the student will receive an essay on the order in hand;

real comments and feedback about each expert help to navigate, who to approach and what results to expect.

If you need to order essay on any subject, be sure to contact author of essay on here will execute any order with pleasure and in the shortest time will help you to come to the school with the custom essay uk and best hand.

Other types of work

To the exchange author of essay each day addresses a lot of clients that need professional help. Here  who can do the work of proofreading efficiently and competently. author of essay has such features as:

It employs a lot of specialists who work with different languages. The staff is constantly to big this allows us to assist a lot more often;

The order is carried out only by experienced professionals who have diploma in this field or are the academic staff of the Universities. They thoroughly know their work and can carry out proofreading of articles;

The cost of proofreading text

Exchange author of essay can perform all sorts of work. Proofreading articles, research papers and other assignments is in accordance with all requirements and regulations. As for the cost of proofreading the texts, it may depend on:

Scope of work;

The complexity of the subject;

Deadlines.

For urgent execution, the contractor takes a percentage of the work, as it delays other work and perform an urgent task.

Posted in SQL Server | Leave a comment

EF Core 2.1 Roadmap

A network of casinos no! How so, asks the inquisitive reader, was just saying that though and I myself am about ten seen, and heres to you, “no.” Yes, dear, no. But there is a program — a gaming machine which simulates anything. And roulette, blackjack, and Poker, etc. And the program “personal use”. Ie, you play with her one on one. Of course, at the same time on the server may be at least 100 people. But play you all one of his “table”, i.e. by running this program on your computer. And your situation in no way affects other players as well as their situation, you. Thus, it violated that Golden rule — do not play against the casino. And the player is in this situation — one against the casino (or rather against its gaming machine). And what is the casino going to let him with impunity “stripped” with the help of different gaming systems? Hehe, guys, we casino was built. What would you have “stripped” ? As it is not so…

Pay attention to casino rules. Rights of the player virtually no. Yes, and they cannot be! The fact that even the law gaming situation may not be in dispute. “Well, damn you, buddy! Well, that thing went to!” And everything was your money become our money.

Because the online casino is just slot machine, what prevents you to configure it the way the owner wants it? Indeed, to prove it is absolutely impossible — “we have all accidentally” say the guys in the previews of the entrance.

But only a foolish fisherman going fishing dont take the bait. Sometimes a lot. But since you played “for free”, you do not deserve. And in the soul of the player settles the worm. Yeah, but would I real money, the evening of three hundred would have done a couple of thousand… And it seems to him that he start all over again, the situation will simply repeat itself, but with real money.

Then the player receives a loading dose of bait — “In our casino, if you drive in the game$ 100, get a bonus — another$ 100!” this like online jackpot city casino review on freepokiesland.com To remove them at once is impossible, but to play on. E-my, well, who would refuse! Well, not to swallow this lure of  doubling the money may just very well mentally stable fish. Of which minority.

And thats when the game is already in the money, the adult thing here is to beat the player by using the programmed machine is easier than kindergartners take a toy. You can even give a little and win (and where are you from a submarine go?). Brought$ 100, won another 50, Yes the bonus (non-removable) money hundreds. Come on, buddy, come to us for fifty dollars come from? Well, you Somni, as it was last time — a couple of thousand, easy! Here then is the conversation!

And at some moment a lucky player suddenly stops take. Nonsense, the case, he thinks. On it and casino, then black, then red… no way, man… Maybe for a normal, wooden roulette wheel and case (and even then, Matera dealer can “sector” to throw), and electronic program everything is under control. Then the moneyat stake. And the luckiest game system suddenly stops working!

And she cant work, because it is no longer the game itself. There is a cunning program of the slot machine. The task of which is relatively honest and was not penalized taking money from citizens.

And whats interesting. The machine works on its own, but the player still plays and the role of the dealer. He presses the button “start” and himself throws the ball.

In principle, all these beautiful pictures in the form of a spinning roulette ball rolling (Yes, even with the imitation of the sound) and the loss of any digits — solid props. Well, kind of like the scenery on the stage. If the player will simply announce the number of the dropped numbers, nothing will change.

All of the above allows us to state that real casino to the Internet, alas, no. Have to try your luck in those that are everyones business. I warned, who did not hide I is not guilty.

But in General, can the casino to be in online? Of course you can. But the Internet in this case should be the only method of communication. Implementation is, in my opinion, there are two.

The easiest is simply an organization web camera on a real roulette. Player just (brokered or dealer) bets. And the game can be a lot of players. And the dealer is true and real, real roulette turns and throws the real ball. And the result is visible to all players. In real-time and simultaneously. Yes, it more expensive than to do the slot machine. But this casino and trust more. Its just remote play in a real casino.

The second option is. In principle, the machine is also not very bad. But it is important to do it in a way that would at the same table at the same time playing a few players. And betting players should be visible to other players. This option also has the right to life, and imitation of other players. While, however, it is quite easy to check if in the game will participate in 2-3 pre-collusion between a person. And in any case, the belief that roulette is as much more. Even if your losing, you will see that someone still wins. So the gain is possible?

To play in the current online casino, one-on-one with the shifty program I do not advise.

Posted in ORM | Comments Off on EF Core 2.1 Roadmap

Write a program that prints an average temperatue that is close to Zero

The idea is to get the lowest number that is close to the value zero (irrespective of the negative or positive value) from an array of average temperatures that are supplied like so:

{ 7, 7.9, 10.5, -4, 3, -6, -2, 1, -15, 11.3, 9, -1 }

Solution:
One way is to iterate through an array of numbers and store the lowest number in a temp variable and print it out to a console.

As a side, an Array class provides methods for creating, manipulating, searching arrays which serves as the base class for all arrays in common language runtime typically referred to as CLR. The array data structure contains a contiguous collection of data items that can be accessed by an ordinal index.

I have assigned an arbitrary value of 50 to the temp variable prior to iterating through the array elements, comparing it and assigning the lowest number to the temp variable until it reaches the last element of the array before printing out the number.

public static void GetTemperatureCloseToZero()
        {
            double temp = 50.0; //some arbitrary value
            double diff;
            int target = 0;

            double[] arr = { 7, 7.9, 10.5, -4, 3, -6, -2, 1, -15, 11.3, 9, -1 };

            for (int i = 0; i < arr.Length; i++)
            {
                diff = Math.Abs(Convert.ToDouble(arr[i])) - Convert.ToDouble(target);
                if (diff <= temp)
                {
                    temp = diff;
                }
            }
            Console.WriteLine("The closest value to 0 is: {0}", temp);
            Console.ReadLine();
        }

Alternative Solution:
If you don't want to iterate through the items in an array, you can also use the Sort() method to sort elements in the entire list using the default comparer like so:

       public static void GetTempCloseToZeroSort()
        {
            double[] arr = { 7, 7.9, 10.5, -4, 3, -6, -2, 1, -15, 11.3, 9, -1 };
            List list = new List();

            foreach (var item in arr)
            {
                list.Add(Math.Abs(item));
            }
            list.Sort();
            
            Console.WriteLine("The closest value to 0 is: {0}", list[0]);
            Console.ReadLine();
        }

In both case the code produces the following output:ArrayOut1

I hope this will help those that are just getting into data structures.

Cheers,

Obi

 

Posted in Algorithms & Data Structures | Comments Off on Write a program that prints an average temperatue that is close to Zero

How to check if nested brackets are in the correct logical order

I am starting a series of blog posts on algorithms and data structures with the first one being the easiest!

Q. Write a method that checks if the nested brackets are in the correct logical order. The input string is the following:

“{ [ () {} ] }”

Please note, there can be many interpretations, but here’s how I am attempting to solve this question which may not necessarily be the most efficient solution. Here it goes…

First off, I create a console app and write a function that removes erroneous spaces like so:

 
        public static String FilterErroneousChars(String input)
        {
            int len = input.Length;
            char[] arr = input.ToCharArray();
            String filter = "";
            for (int i = 0; i < len; i++)
            {
                if (arr[i].Equals('(') || arr[i].Equals(')') || arr[i].Equals('[') || arr[i].Equals(']') || arr[i].Equals('{') || arr[i].Equals('}'))
                {
                    filter += arr[i];
                }
            }
            return filter;
        }

Once the function is executed, it'll return a string with no spaces, i.e. "{[(){}]}".

Next, I call the method from Program Main() and pass in the compressed string as input like so:

Then, I check to see if any of the nested pair(s) is equal. If the condition is met, the program replaces the nested brackets with an empty string until there's nothing left.

In the end, I check to see if the length of the string is 0. Once this condition evaluates to True, we know, that the input string is well-formed, else NOT.

I hope, those of you that are new to data structures, you might find this algorithmic exercise useful.

String s = Algorithms.FilterErroneousChars("{ [ () {} ] }");
            while ((s.Length != 0) && (s.Contains("[]") || s.Contains("()") || s.Contains("{}")))
            {
                s = s.Replace("[]", "");
                s = s.Replace("()", "");
                s = s.Replace("{}", "");
            }

            if (s.Length == 0)
            {
                Console.WriteLine("Well Formed");
            }
            else
            {
                Console.WriteLine("Not Well Formed");
            }

Posted in Algorithms & Data Structures | Comments Off on How to check if nested brackets are in the correct logical order

What package(s) do I need for EF Core 2.x?

First off, it is important to note that there are a couple of ways to download package(s).
1. You can use NuGet right from inside Visual Studio IDE
2. You can also use CLI (Command Line Interface)

Here, I’ll demonstrate both of them.

Even though you could install Microsoft.EntityFrameworkCore, however, you would need a database provider to interact with. Given, that EF Core is modular, and depending on the data-store you want to work with, you would only need to install that specific database provider.

Unlike EF 6.x, where SQL Server is the default database provider; that is not the case with EF Core. EF Core supports a variety of databases that include the following:

  • Microsoft SQL Server
  • SQLite
  • Postgres SQL
  • MySQL
  • SqlServerCompact (By Erik Jensen)
  • In-Memory Testing

When using CLI, you would want to install the following by navigating to Tools – NuGet Package Manager – Package Manager Console.

c:\Install-Package Microsoft.EntityFrameworkCore.SqlServer

If you wish to create a database using Migrations from your POCO classes or what is typically referred as Code-First workflow, you would need to install the following from the command line:

c:\Install-Package Microsoft.EntityFramework.Tools

You might also need Design tools in the event you want to create Controllers and Views using the Scaffolding feature of ASP.NET Core MVC. This can be obtained by installing the following:

c:\Install-Package Microsoft.VisualStudio.Web.CodeGeneration.Design

In the event where you want to use Visual Studio’s IDE, you can simply navigate to Tools – NuGetPackageManager – Manage NuGet Packages for Solution.

Once, the NuGet Window opens up, you can type in the appropriate package in the Search text field which will give you a list of stable packages unless you check the Include Prerelease check box to the right of the search field.

That’s all there is to it!

Posted in ORM | Comments Off on What package(s) do I need for EF Core 2.x?

Mongo DB and .NET

This is my last blog post of the year 2017 where I am going to showcase how you can make the .NET application talk to a Mongo DB.

Just a quick recap…MongoDB is a document database that stores data in flexible, JSON-like documents, meaning fields can vary from document to document and data structures can be changed over time.

If you want to know about Mongo DB, what it is and why you should use it, you can read the article from one of my earlier posts here.

First things first, install the following:

  • Robo 3T from www.robomongo.org

Robo 3T (formerly Robomongo) is the free lightweight GUI embedded shell for MongoDB users.

Launch Visual Studio and create a Console App (.NET Framework).

Now install the following packages from NuGet:

  • MongoDB.Bson
  • MongoDB.Driver
  • MongoDB.Driver.Core

Packages

It’s time to write some code, but before that, add references to the project and use the following namespaces:

using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using System;
using System.Linq;

Let’s create a POCO class and call it Book. This is done in order for the document model to map to the objects in the application code therefore making data easy to work with.

    public class Book
    {
        public  ObjectId Id { get; set; }
        public string ISBN { get; set; }
        public string Title { get; set; }
        public string Author { get; set; }
        public DateTime Published { get; set; }
        public string Publisher { get; set; }
    }

Let’s insert a record into the book collection like so:

private static void InsertBook()
        {
            var client = new MongoDB.Driver.MongoClient();
            var db = client.GetDatabase("admin");
            var col = db.GetCollection("Books");

            Book objBook = new Book();
            objBook.Id = ObjectId.GenerateNewId();
            objBook.ISBN = "593220";
            objBook.Title = "Debgging Mongo App";
            objBook.Author = "Obi Oberoi, Ken Cenerelli";
            objBook.Published = Convert.ToDateTime("2017-12-31T00:00:00Z");
            objBook.Publisher = "Wrox";

            col.InsertOne(objBook);
        }

To get a book collection, use the code below:

private static void GetAllBooks()
        {
            var client = new MongoDB.Driver.MongoClient();
            var db = client.GetDatabase("admin");
            var col = db.GetCollection("Books");

            foreach(Book doc in col.Find(b=> b.Title.Length > 0)
                    .SortByDescending(b=> b.Title)
                    .ToList())
            {                
                Console.WriteLine("BookID: {0}", doc.Id);
                Console.WriteLine("Title: {0}", doc.Title);
                Console.WriteLine("Author: {0}", doc.Author);
            }
            Console.ReadLine();
        }

Let’s take our code to test by calling the methods from the Main program:

static void Main(string[] args)
        {         
            InsertBook();
            GetAllBooks();            
        }

As you saw in just a few lines of code, one could easily perform CRUD operations against MongoDB with a CLR compliant language such as C#.

Posted in NoSQL | Comments Off on Mongo DB and .NET

What is the difference between Delete and Truncate

To order essay on an author of the essay not only that but safely. Our exchange provides a number of obligations, which guarantee customers that they will receive a high quality and decent work:

each essay is checked by the system Antiplagiat, which ensure that the text was unique;

you made your payment remains “frozen” for the author until the time the student will receive an essay on the order in hand;

real comments and feedback about each expert help to navigate, who to approach and what results to expect.

If you need to order essay on any subject, be sure to contact author of essay on here will execute any order with pleasure and in the shortest time will help you to come to the school with the custom essay uk and best hand.

Other types of work

To the exchange author of essay each day addresses a lot of clients that need professional help. Here  who can do the work of proofreading efficiently and competently. author of essay has such features as:

It employs a lot of specialists who work with different languages. The staff is constantly to big this allows us to assist a lot more often;

The order is carried out only by experienced professionals who have diploma in this field or are the academic staff of the Universities. They thoroughly know their work and can carry out proofreading of articles;

The cost of proofreading text

Exchange author of essay can perform all sorts of work. Proofreading articles, research papers and other assignments is in accordance with all requirements and regulations. As for the cost of proofreading the texts, it may depend on:

Scope of work;

The complexity of the subject;

Deadlines.

For urgent execution, the contractor takes a percentage of the work, as it delays other work and perform an urgent task.

Posted in ORM | Comments Off on What is the difference between Delete and Truncate

What are Nested Transactions in SQL Server?

As the name suggests, nested transaction is one that is nested within a transaction. Let’s illustrate this with an example.

Let’s create a table:

CREATE TABLE PERSON
(
	ID INT IDENTITY(1,1),
	FirstName VARCHAR(25),
	LastName VARCHAR(25),
	Gender CHAR(1)
)
SELECT * FROM PERSON

As you can see, we have a table Person with no records.


Let’s initialize a transaction and view its count

BEGIN TRANSACTION  -- 1st Transaction
SELECT @@TRANCOUNT AS TrxCount

Now, insert a record into the table

INSERT INTO PERSON VALUES ('Bill', 'Meyer', 'M')
SELECT * FROM PERSON

Let’s initialize a second transaction and view its count:

BEGIN TRANSACTION -- 2nd Transaction
SELECT @@TRANCOUNT AS TrxCount

Let’s insert another record and then view its contents. Mind you, we are currently in a nested transaction.

INSERT INTO PERSON VALUES ('Lisa', 'Ray', 'F')
SELECT * FROM PERSON

Now, let’s rollback the transaction and do a count immediately afterwards.

--Rollback Transaction
ROLLBACK
SELECT * FROM PERSON
SELECT @@TRANCOUNT AS TrxCount


The rollback rollsback to the outermost transaction that was defined. Another thing to keep in mind is that you don’t need a COMMIT TRANSACTION in order to ROLLBACK.

Posted in SQL Server | Comments Off on What are Nested Transactions in SQL Server?

How to partition the result set in SQL Server

To query the first row or the last row in a table is easy-piecey.  You simply select the Top 1 row and order the query by ascending or descending. But, how about selecting the second, third or tenth row from a table that meets a certain criteria. That’s when the query gets little tricky.

I’ll show you an easy approach from start to finish. Below is a snapshot of an Employee table with a list of employees and their salaries. The Employee table as you can see is ordered by ID with a list of random salaries.

Employee Table in Descending Order:

Max Salary:

To get a maximum salary from the employee table, the MAX() function is used to get the value. Easy eh!

How about if you want to get the second highest salary? How would you shape your query? One way is to write a sub-query like so:

SELECT MAX(Salary) AS 'Max Salary'
FROM
	Employee
WHERE
	Salary < (SELECT MAX(Salary) FROM Employee)


OR

You can also do something like this, although you'll have to do a mental math to write the following query in order to get the second highest salary:

SELECT
	TOP 1 Salary 
FROM
	(SELECT DISTINCT TOP 2 Salary
	FROM
		Employee
	ORDER BY 
		Salary DESC)
	RESULT
ORDER BY
	Salary

Using DENSE_RANK() function:

WITH RESULT AS
(
SELECT Salary, DENSE_RANK() OVER (ORDER BY Salary DESC) AS RANK
FROM
	Employee
)
Select TOP 1 Salary from RESULT
WHERE RANK = 3

Summary:

The thing to remember is that numbers returned by DENSE_RANK function do not have gaps and invariably use consecutive ranks.

Happy coding 🙂

Resources

Microsoft

Posted in SQL Server | Comments Off on How to partition the result set in SQL Server

What is Mongo DB and why should you use it!

The word Mongo is derived from the world humongous. So in essence, it implies that its sole purpose is to store mammoth amounts of data or what is otherwise coined as ‘big data’.

MongoDB is a document oriented database unlike its traditional relational counterparts such as SQL Server, DB2, Oracle, PostgreSQL etc.  MongoDB uses a JSON like syntax which is made up of name value pairs.

The fact that MongoDB is a document database, one of the rules that govern MongoDB is that every document must be unique. Hence it should have an ID. It’s also important to remember that the size of this document is typically 16MB.

MongoDB is elastic and therefore scales horizontally unlike RDBMS that scale vertically.

One of the key concepts of MongoDB is that there should always be a copy of the primary database (although not required), it is recommended that there be at least two copies of a database. In the event of a failure of primary database, the database can be restored from one of secondary servers.

The world we live in today where businesses are constantly evolving, billions of people and ‘things’ are always communicating, changing the way organizations and customers interact with each other and the environment around them. Data comes from different geographical locations and across multiple channels. Managing this explosion of high-velocity dynamic data while maintaining customer privacy is a challenge with legacy systems to say the least. That said, data is therefore of paramount importance for any organization large or small.

The solution to support rapidly growing applications is to scale horizontally by adding servers instead of concentrating more capacity in a single server. NoSQL databases, on the other hand, usually support auto-sharding, meaning that they natively and automatically spread data across an arbitrary number of servers, without requiring the application to even be aware of the composition of the server pool. Data and query load are automatically balanced across servers, and when a server goes down, it can be quickly and transparently replaced with no application disruption. This is especially an ideal situation for web applications.

While it is true that NoSQL databases lack transaction support and semantics database element that offers guarantees about data consistency and persistence. This is a solid tradeoff based on MongoDB’s goal of being simple, fast, and scalable. Once you leave those heavyweight features at the door, it becomes much easier to scale horizontally.

Some of the big 20 companies such as Google, Facebook, LinkedIn use NoSQL databases and it fits very well with their business model. That said, MongoDB has truly become a global company with over 50,000 members, 100 User Groups all around the world. As it stands right now, MongoDB has 29 offices in 14 different countries with over 3000 customers.

What’s in MongoDB

  • Key-values stores (JSON like syntax i.e. key/value pairs)
  • Column Family Stores (hierarchical schemas)
  • Document Databases
  • Multi-nested data
  • High velocity data coming at a very high rate of speed
  • Graph Databases
  • Unstructured data and by not enforcing transactional consistency
  • Document oriented databases are schema-agnostic. This allows for agility and highly iterative development
  • Durability when used in tandem with at least three servers (minimum)
  • Profiling Queries

Types of NoSQL Databases

Is MongoDB the Right Choice?

While it’s all fine and dandy to jump to this new shiny NoSQL database, but you ought to step back and ask yourself the following questions:

  • What are some of characteristics of my data?
  • What are the business needs of my data?
  • Am I required to query across multiple tables and possibly across multiple databases?
  • Do I need my data to be transactional?

Benefits

There’s no question, when compared to relational databases, NoSQL databases are more scalable and provide superior performance. Following are some of its benefits:

  • Speed and large volumes of rapidly changing structure, semi-structure and unstructured data
  • Open source, hence mostly Free
  • Object-oriented programming that is easy to use and flexible
  • Simplicity (with virtually no complex rules i.e. tables, relationships and less Object-Relational impedance mismatch
  • Geographically distributed scale-out architecture instead of expensive, monolithic architecture

Format

MongoDB uses an open data forma called BSON which is similar to the JSON format. The BSON data format was developed by the MongoDB team. This format is special in that it facilitates searching of documents rapidly including the ability to add types for handling binary data. MongoDB stores data in BSON documents which is self-contained.

Scaling

Relational databases are designed to scale vertically, in that a single server has to host the entire database to ensure acceptable performance for cross-table joins and transactions. This can become an expensive proposition while placing limits on scale. The solution to support rapidly growing applications is to scale horizontally, by adding servers or cloud instances instead of concentrating more capacity in a single server.

References

www.MongoDB.com

http://Dataconomy.com/sql-vs-nosql-need-know

Posted in NoSQL | Comments Off on What is Mongo DB and why should you use it!