There are times when you would be required to delete all the records from the table using Entity Framework. One of the commonly used approach is to iterate each rows and use the DBSet.Table.Remove as shown below. How to Quickly Delete All Rows in a Table in Entity Framework? The Other quickest simple option to […]
If you want to ignore a class property in Entity Framework , you can mark the property with the NotMapped data annotations. How to Ignore a Class Property in Entity Framework ? Below is a sample code snippet show how you can apply the NotMapped data annotations.
There are times when you have to remove duplicate entried from a List from Your C# program and one of the easiest way to do that is using the combination of the LINQ and IEqualityComparer interface. Assume that you have a list of Actors as shown below ID : 1 , Name = Vijay ,Language […]
If you need a way to get the size of a file in your C# program , you can use the Length property of the FileInfo class. How to Get the File Size in C# ? FileInfo.Length returns the length of the file in bytes.
This post will provide a simple tip showing how you can get the last 4 characters from a string in C#. How to get last four characters from a string in C#? Assume that you have a string that contains the value “CodersEditor.com” and you wish to get .com from the string and display it. […]
Assume that you have the .NET Framework installed on your machine and you wish to install Windows Service via command prompt in Windows. In this case , you can use install the service using installutil.exe as shown below. “C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe” “c:\abundantcodeService.exe” Incase you have a 64 bit version of the framework , ensure that you refer […]
When using C# programming language , there are times when you might want to skip over the iteration based on some condition and jump over to the next iteration. How to Skip Iteration of a foreach loop in C# ? continue keyword comes to your rescue for this use case. When you want to skip […]
If you are looking at ways to accept only digits and decimal points (numeric input) for a textbox in WPF , you could do it by following the below steps. How to Allow only numeric input in a Textbox in WPF ? Add the Event PreviewTextInput for the Textbox in the XAML. In the Xaml.cs […]
There are times when you want to calculate MD5 checksum for a file in C# and you can easily do that using System.Security.Cryptography.MD5 You can use the ComputeHash method of the MD5 instance by passing the stream. You can later it to Hex using the BitConverter so that you can represent it as string for […]
If you are looking at finding out what could be the best data type for currency in C# ?, this post will provide a quick tip or insights on the same. What is the best data type for Currency in C#? Use decimal for any currency or money values. The decimal keyword indicates a 128-bit […]