<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: manoj</title>
    <description>The latest articles on DEV Community by manoj (@jsdevelopermano).</description>
    <link>https://dev.to/jsdevelopermano</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F285534%2F460734f4-08fb-4350-8c7a-8ce3fc657bda.png</url>
      <title>DEV Community: manoj</title>
      <link>https://dev.to/jsdevelopermano</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jsdevelopermano"/>
    <language>en</language>
    <item>
      <title>DSA: Linked List Javascript</title>
      <dc:creator>manoj</dc:creator>
      <pubDate>Fri, 02 Aug 2024 12:57:18 +0000</pubDate>
      <link>https://dev.to/jsdevelopermano/dsa-linked-list-javascript-3340</link>
      <guid>https://dev.to/jsdevelopermano/dsa-linked-list-javascript-3340</guid>
      <description>&lt;p&gt;LinkedList is the &lt;em&gt;dynamic&lt;/em&gt; data structure, as we can add or remove elements at ease, and it can even grow as needed. Just like &lt;em&gt;arrays&lt;/em&gt;, linked lists store elements sequentially, but don’t store the elements contiguously like an array.&lt;/p&gt;

&lt;p&gt;We define a class Node having two properties: element and next. Element holds the data of a node while next holds the pointer to the next node, which is initialized to the null value.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyi3vwbyq52qjomgh24ck.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyi3vwbyq52qjomgh24ck.png" alt=" " width="800" height="233"&gt;&lt;/a&gt;&lt;br&gt;
Let's visualize the memory updates step-by-step:&lt;/p&gt;

&lt;p&gt;Initial State:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;head -&amp;gt; @A1
@A1: { value: 10, next: null }
tail -&amp;gt; @A1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After First Append:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;head -&amp;gt; @A1
@A1: { value: 10, next: @B1 }
tail -&amp;gt; @B1
@B1: { value: 5, next: null }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After Second Append:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;head -&amp;gt; @A1
@A1: { value: 10, next: @B1 }
@B1: { value: 5, next: @C1 }
tail -&amp;gt; @C1
@C1: { value: 16, next: null }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The entire list structure due to the updates to the next properties.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  value: 10,
  next: {
    value: 5,
    next: {
      value: 16,
      next: null
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Conclusion&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;tail.next&lt;/code&gt; = &lt;code&gt;newNode&lt;/code&gt; updates the &lt;code&gt;next&lt;/code&gt; property of the current &lt;code&gt;tail&lt;/code&gt; node to reference the new node.&lt;/li&gt;
&lt;li&gt;This creates a chain of references starting from &lt;code&gt;head&lt;/code&gt; and extending through each appended node.&lt;/li&gt;
&lt;li&gt;Each &lt;code&gt;append&lt;/code&gt; operation extends the linked list, making the new node part of the chain that &lt;code&gt;head&lt;/code&gt; points to.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Therefore, while &lt;code&gt;head&lt;/code&gt; itself doesn't change, the structure it references gets updated with each new node appended, because &lt;code&gt;head.next&lt;/code&gt; (and subsequent &lt;code&gt;next&lt;/code&gt; properties) form a chain that includes all nodes, old and new.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://replit.com/@manojantony/linkedList" rel="noopener noreferrer"&gt;Demo&lt;/a&gt;&lt;/p&gt;

</description>
      <category>datastructures</category>
      <category>linkedlist</category>
      <category>javascript</category>
    </item>
    <item>
      <title>The Angular Advantage: Simplifying Development with Unidirectional Flow and Presentational Components</title>
      <dc:creator>manoj</dc:creator>
      <pubDate>Fri, 05 Jul 2024 11:07:45 +0000</pubDate>
      <link>https://dev.to/jsdevelopermano/the-angular-advantage-simplifying-development-with-unidirectional-flow-and-presentational-components-27g</link>
      <guid>https://dev.to/jsdevelopermano/the-angular-advantage-simplifying-development-with-unidirectional-flow-and-presentational-components-27g</guid>
      <description>&lt;p&gt;&lt;strong&gt;Simplifying Angular Applications: Unidirectional Data Flow and Presentational Components&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Building complex Angular applications can lead to tangled logic and data management headaches. Traditional approaches often involve components manipulating data directly, making it difficult to track changes and maintain a consistent state. Here, we explore two key concepts that can significantly improve your Angular development experience: Unidirectional Data Flow and Presentational Components.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Unidirectional Data Flow: A Streamlined Approach&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imagine data flowing through your application like a river. Traditionally, this flow could be chaotic, with data changing hands between components in unpredictable ways. Unidirectional Data Flow introduces a clear path for this "river" of data. Here's how it works:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;User interacts:&lt;/strong&gt; A user clicks a button, selects an item, or submits a form.&lt;br&gt;
Component dispatches action: The component responsible for handling the user interaction dispatches an action. Think of an action as a message containing information about the event.&lt;br&gt;
&lt;strong&gt;Store updates state:&lt;/strong&gt; A centralized store, managed by NgRx or a similar library, receives the action and updates the application state accordingly.&lt;br&gt;
&lt;strong&gt;Component retrieves data:&lt;/strong&gt; The component subscribes to a selector, a function that retrieves specific data slices from the updated state.&lt;br&gt;
&lt;strong&gt;Component updates UI:&lt;/strong&gt; Based on the retrieved data, the component updates the user interface (UI) to reflect the changes.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// actions.ts
export const increment = createAction('[Counter] Increment');
export const decrement = createAction('[Counter] Decrement');

// reducer.ts
const initialState = { count: 0 };

export const counterReducer = createReducer(
  initialState,
  on(increment, (state) =&amp;gt; ({ count: state.count + 1 })),
  on(decrement, (state) =&amp;gt; ({ count: state.count - 1 }))
);

// counter.component.ts
@Component({
  selector: 'app-counter',
  template: `
    &amp;lt;button (click)="dispatchIncrement()"&amp;gt;Increment&amp;lt;/button&amp;gt;
    &amp;lt;button (click)="dispatchDecrement()"&amp;gt;Decrement&amp;lt;/button&amp;gt;
    &amp;lt;p&amp;gt;Count: {{ count$ | async }}&amp;lt;/p&amp;gt;
  `,
})
export class CounterComponent {
  count$ = this.store.select(selectCount);

  constructor(private store: Store&amp;lt;AppState&amp;gt;) {}

  dispatchIncrement() {
    this.store.dispatch(increment());
  }

  dispatchDecrement() {
    this.store.dispatch(decrement());
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This unidirectional flow offers several advantages:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Predictability:&lt;/strong&gt; Since data flows in a single direction, it's easier to understand how changes in one part of the application affect others.&lt;br&gt;
&lt;strong&gt;Debugging:&lt;/strong&gt; With a clear path, debugging becomes simpler as you can pinpoint where data manipulations occur.&lt;br&gt;
&lt;strong&gt;Testability:&lt;/strong&gt; Unidirectional flow makes components easier to test in isolation, as they rely solely on actions and selectors for data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Components as Presentational Layers:&lt;/strong&gt; Keeping it Clean&lt;br&gt;
Imagine your components as display cases in a museum. Their primary purpose is to showcase information, not manipulate it directly. By adopting the "presentational component" approach, you achieve this goal:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Components focus on presentation:&lt;/strong&gt; These components handle user interactions and display data, but they don't modify the application state themselves.&lt;br&gt;
Separation of concerns: This separation keeps your code organized and easier to maintain.&lt;br&gt;
&lt;strong&gt;Reusable components:&lt;/strong&gt; Presentational components often become reusable across different parts of your application since they don't rely on application-specific logic.&lt;br&gt;
The Synergy of Unidirectional Data Flow and Presentational Components&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// user-card.component.ts
@Component({
  selector: 'app-user-card',
  template: `
    &amp;lt;div *ngIf="user"&amp;gt;
      &amp;lt;h2&amp;gt;{{ user.name }}&amp;lt;/h2&amp;gt;
      &amp;lt;p&amp;gt;Email: {{ user.email }}&amp;lt;/p&amp;gt;
    &amp;lt;/div&amp;gt;
  `,
})
export class UserCardComponent {
  @Input() user: User | null = null;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Combining these two concepts creates a powerful development approach. Unidirectional data flow ensures predictable state management, while presentational components keep the logic clean and focused. This synergy leads to maintainable, testable, and scalable Angular applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ready to Streamline Your Development?&lt;/strong&gt;&lt;br&gt;
Unidirectional data flow and presentational components represent a paradigm shift in Angular development. By embracing these strategies, you can build more robust and manageable applications, allowing you to focus on what matters most - delivering an exceptional user experience.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Unidirectional Data Flow with NgRx Wins for Large-Scale Angular Applications&lt;/strong&gt;&lt;br&gt;
While traditional two-way data binding and service layers with event emitters have their merits, for large-scale Angular applications, unidirectional data flow with NgRx offers several advantages:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Improved Scalability and Maintainability:&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Complexity Management:&lt;/strong&gt; Two-way data binding can become a tangled mess in large applications, making it difficult to track data flow and identify issues. NgRx provides a centralized store, simplifying state management and reducing the risk of bugs.&lt;br&gt;
&lt;strong&gt;Predictable Changes:&lt;/strong&gt; Unidirectional data flow ensures predictable state updates, making it easier to reason about how changes in one part of the application affect others. This becomes crucial as the application grows and components become more interconnected.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Enhanced Testability:&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Isolated Testing:&lt;/strong&gt; Components in a unidirectional flow architecture rely solely on actions and selectors to interact with the state. This allows for easier unit testing of components in isolation, as you don't need to mock complex data interactions.&lt;br&gt;
&lt;strong&gt;Debugging Benefits:&lt;/strong&gt; Since data changes follow a clear path, debugging becomes more efficient. You can pinpoint where state updates occur and identify the root cause of issues.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Better Performance and Data Consistency:&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Immutable State:&lt;/strong&gt; NgRx promotes immutability, meaning the state store never gets mutated directly. This improves performance and ensures data consistency across the application.&lt;br&gt;
&lt;strong&gt;Performance Optimizations:&lt;/strong&gt; NgRx offers features like memoization for selectors, which can improve performance by caching frequently used data slices.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Developer Experience and Team Collaboration:&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Clear Communication:&lt;/strong&gt; Unidirectional data flow fosters a clear understanding of how data flows within the application. This improves communication and collaboration within development teams.&lt;br&gt;
&lt;strong&gt;Reusable Patterns:&lt;/strong&gt; NgRx promotes well-defined patterns for actions, reducers, and selectors, making code more reusable and maintainable across different parts of the application.&lt;/p&gt;

&lt;p&gt;While service layers with event emitters offer some benefits, they can still lead to complex data flows and tight coupling between components. Unidirectional data flow with NgRx provides a structured and scalable approach to managing application state, especially for large-scale Angular applications.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>C# IEnumerables</title>
      <dc:creator>manoj</dc:creator>
      <pubDate>Fri, 28 Jun 2024 02:54:53 +0000</pubDate>
      <link>https://dev.to/jsdevelopermano/c-ienumerables-2bbi</link>
      <guid>https://dev.to/jsdevelopermano/c-ienumerables-2bbi</guid>
      <description>&lt;h2&gt;
  
  
  Key Points:
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is IEnumerable?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;IEnumerable&lt;/code&gt; is an interface in C# that allows you to iterate over a collection of items.&lt;/li&gt;
&lt;li&gt;It is found in the &lt;code&gt;System.Collections&lt;/code&gt; namespace for non-generic collections and &lt;code&gt;System.Collections.Generic&lt;/code&gt; namespace for generic collections.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Methods and Properties
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The primary method in &lt;code&gt;IEnumerable&lt;/code&gt; is &lt;code&gt;GetEnumerator()&lt;/code&gt;, which returns an &lt;code&gt;IEnumerator&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;IEnumerator&lt;/code&gt; provides the necessary methods (&lt;code&gt;MoveNext()&lt;/code&gt;, &lt;code&gt;Reset()&lt;/code&gt;) and property (&lt;code&gt;Current&lt;/code&gt;) to iterate over a collection.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Common Usage
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;IEnumerable&lt;/code&gt; is commonly used with &lt;code&gt;foreach&lt;/code&gt; loops to traverse collections such as arrays, lists, and other data structures.&lt;/li&gt;
&lt;li&gt;It provides a standard way to iterate over any collection that implements the interface.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Examples of Methods
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;OfType&amp;lt;TResult&amp;gt;(IEnumerable)&lt;/code&gt;&lt;/strong&gt;: Filters the elements of an &lt;code&gt;IEnumerable&lt;/code&gt; based on a specified type.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;Concat&amp;lt;TSource&amp;gt;(IEnumerable&amp;lt;TSource&amp;gt;, IEnumerable&amp;lt;TSource&amp;gt;)&lt;/code&gt;&lt;/strong&gt;: Concatenates two sequences.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;GroupBy&amp;lt;TSource,TKey&amp;gt;(IEnumerable&amp;lt;TSource&amp;gt;, Func&amp;lt;TSource,TKey&amp;gt;)&lt;/code&gt;&lt;/strong&gt;: Groups the elements of a sequence according to a specified key selector function.&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>Visualize dependencies across your code with code maps in Visual Studio 2019</title>
      <dc:creator>manoj</dc:creator>
      <pubDate>Thu, 14 Oct 2021 16:06:53 +0000</pubDate>
      <link>https://dev.to/jsdevelopermano/visualize-dependencies-across-your-code-with-code-maps-in-visual-studio-2019-3lfk</link>
      <guid>https://dev.to/jsdevelopermano/visualize-dependencies-across-your-code-with-code-maps-in-visual-studio-2019-3lfk</guid>
      <description>&lt;p&gt;(1). In Solution Explorer, select the projects, assembly references, folders, files, types, or members that you want to map.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffgg5qkwh5bu2roo0it7q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffgg5qkwh5bu2roo0it7q.png" alt=" " width="501" height="739"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(2). On the Solution Explorer toolbar, choose Show on Code Map Create New Graph From Selected Nodes Button. Or, open the shortcut menu for one or a group of items and choose Show on Code Map.&lt;/p&gt;

&lt;p&gt;You can also drag items from Solution Explorer, Class View, or Object Browser, into a new or existing code map. To include the parent hierarchy for your items, press and hold the Ctrl key while you drag items, or use the Include Parents button on the code map toolbar to specify the default action. You can also drag assembly files from outside Visual Studio, such as from Windows Explorer.&lt;/p&gt;

&lt;p&gt;(3). The map shows the selected items within their containing assemblies.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl769tyi2jaomq4ahgt23.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl769tyi2jaomq4ahgt23.png" alt=" " width="640" height="288"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(4). To explore items, expand them. Move the mouse pointer on top of an item, then click the chevron (down arrow) icon when it appears.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp38x5r2foozz03w1z4bb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp38x5r2foozz03w1z4bb.png" alt=" " width="263" height="182"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To expand all items, select them using Ctrl+A, then open the shortcut menu for the map and choose Group &amp;gt; Expand. However, this option isn't available if expanding all groups creates an unusable map or memory issues.&lt;/p&gt;

&lt;p&gt;(5). Continue to expand items you are interested in, right down to the class and member level if necessary.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flt0pr8l4g23qp50q2zzm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flt0pr8l4g23qp50q2zzm.png" alt=" " width="699" height="670"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To see members that are in the code but don't appear on the map, click the Refetch Children icon Refetch Children Icon in the top left corner of a group.&lt;/p&gt;

&lt;p&gt;(6). To see more items related to those on the map, select one and choose Show Related on the code map toolbar, then select the type of related items to add to the map. Alternatively, select one or more items, open the shortcut menu, and then choose the Show option for the type of related items to add to the map.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsf0t3jat88wlvfi4xu83.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsf0t3jat88wlvfi4xu83.png" alt=" " width="530" height="323"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(7). The map shows the relationships. In this example, the map shows the methods called by the Find method and their location in the solution or externally.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3e90ut7pu3j6yb8miogp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3e90ut7pu3j6yb8miogp.png" alt=" " width="672" height="806"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(8). To simplify the map and focus on individual parts, choose Filters on the code map toolbar and select just the types of nodes and links you are interested in. For example, turn off display of Solution Folders, Assemblies, and Namespaces.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxtnkuzs6wulj6ou2qpgt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxtnkuzs6wulj6ou2qpgt.png" alt=" " width="699" height="647"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ref: &lt;a href="https://docs.microsoft.com/en-us/visualstudio/modeling/map-dependencies-across-your-solutions?view=vs-2019" rel="noopener noreferrer"&gt;https://docs.microsoft.com/en-us/visualstudio/modeling/map-dependencies-across-your-solutions?view=vs-2019&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>C#: Casting and type conversions</title>
      <dc:creator>manoj</dc:creator>
      <pubDate>Wed, 13 Oct 2021 15:21:22 +0000</pubDate>
      <link>https://dev.to/jsdevelopermano/c-casting-and-type-conversions-3fi5</link>
      <guid>https://dev.to/jsdevelopermano/c-casting-and-type-conversions-3fi5</guid>
      <description>&lt;p&gt;C# is statically-type at compile time, after a variable is declared, it cannot be declared again or assigned a value of another type unless that type implicitly convertible to the variable's type.&lt;/p&gt;

&lt;h3&gt;
  
  
  Implicit conversions
&lt;/h3&gt;

&lt;p&gt;For built-in numeric types, an implicit conversion can be made when the value to be stored can fit into the variable without being truncated or rounded off. For integral types, this means the range of the source type is a proper subset of the range for the target type. For example, a variable of type long (64-bit integer) can store any value that an int (32-bit integer) can store. In the following example, the compiler implicitly converts the value of num on the right to a type long before assigning it to bigNum.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Implicit conversion. A long can
// hold any value an int can hold, and more!
int num = 2147483647;
long bigNum = num;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For a complete list of all implicit numeric conversions, see the Implicit numeric conversions section of the Built-in numeric conversions article.&lt;/p&gt;

&lt;p&gt;For reference types, an implicit conversion always exists from a class to any one of its direct or indirect base classes or interfaces. No special syntax is necessary because a derived class always contains all the members of a base class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Derived d = new Derived();
// Always OK.
Base b = d;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Explicit conversions
&lt;/h3&gt;

&lt;p&gt;However, if a conversion cannot be made without a risk of losing information, the compiler requires that you perform an explicit conversion, which is called a cast. A cast is a way of explicitly informing the compiler that you intend to make the conversion and that you are aware that data loss might occur, or the cast may fail at runtime. To perform a cast, specify the type that you are casting to in parentheses in front of the value or variable to be converted. The following program casts a double to an int. The program will not compile without the cast.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Test
{
    static void Main()
    {
        double x = 1234.7;
        int a;
        // Cast double to int.
        a = (int)x;
        System.Console.WriteLine(a);
    }
}
// Output: 1234
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For a complete list of supported explicit numeric conversions, see the Explicit numeric conversions section of the Built-in numeric conversions article.&lt;br&gt;
For reference types, an explicit cast is required if you need to convert from a base type to a derived type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Create a new derived type.
Giraffe g = new Giraffe();

// Implicit conversion to base type is safe.
Animal a = g;

// Explicit conversion is required to cast back
// to derived type. Note: This will compile but will
// throw an exception at run time if the right-side
// object is not in fact a Giraffe.
Giraffe g2 = (Giraffe)a;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A cast operation between reference types does not change the run-time type of the underlying object; it only changes the type of the value that is being used as a reference to that object. For more information, see Polymorphism.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Nullable&lt;T&gt;.HasValue Property</title>
      <dc:creator>manoj</dc:creator>
      <pubDate>Tue, 12 Oct 2021 15:48:23 +0000</pubDate>
      <link>https://dev.to/jsdevelopermano/nullable-t-hasvalue-property-1jhe</link>
      <guid>https://dev.to/jsdevelopermano/nullable-t-hasvalue-property-1jhe</guid>
      <description>&lt;h4&gt;
  
  
  Definition
&lt;/h4&gt;

&lt;p&gt;Gets a value indicating whether the current Nullable object has a valid value of its underlying type.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;public bool HasValue { get; }&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;true if the current Nullable object has a value; false if the current Nullable object has no value.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>C# IEnumerables</title>
      <dc:creator>manoj</dc:creator>
      <pubDate>Thu, 07 Oct 2021 17:12:11 +0000</pubDate>
      <link>https://dev.to/jsdevelopermano/c-ienumerables-5cbo</link>
      <guid>https://dev.to/jsdevelopermano/c-ienumerables-5cbo</guid>
      <description>&lt;p&gt;IEnumerable:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;OfType&amp;lt;TResult&amp;gt;(IEnumerable)&lt;/code&gt; - Filters the elements of an IEnumerable based on a specified type.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Concat&amp;lt;TSource&amp;gt;(IEnumerable&amp;lt;TSource&amp;gt;, IEnumerable&amp;lt;TSource&amp;gt;)&lt;/code&gt; - Concatenates two sequences.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;GroupBy&amp;lt;TSource,TKey&amp;gt;(IEnumerable&amp;lt;TSource&amp;gt;, Func&amp;lt;TSource,TKey&amp;gt;)&lt;/code&gt; - Groups the elements of a sequence according to a specified key selector function.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Entity Framework Core Fluent API</title>
      <dc:creator>manoj</dc:creator>
      <pubDate>Wed, 06 Oct 2021 13:58:21 +0000</pubDate>
      <link>https://dev.to/jsdevelopermano/entity-framework-core-fluent-api-1la8</link>
      <guid>https://dev.to/jsdevelopermano/entity-framework-core-fluent-api-1la8</guid>
      <description>&lt;p&gt;Entity Framework Fluent API is used to configure domain classes to override conventions.&lt;br&gt;
EF Fluent API is based on a Fluent API design pattern (a.k.a Fluent Interface) where the result is formulated by method chaining.&lt;/p&gt;

&lt;p&gt;In Entity Framework Core, the ModelBuilder class acts as a Fluent API. By using it, we can configure many different things, as it provides more configuration options than data annotation attributes.&lt;/p&gt;

&lt;p&gt;Entity Framework Core Fluent API configures the following aspects of a model:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Model Configuration: Configures an EF model to database mappings. Configures the default Schema, DB functions, additional data annotation attributes and entities to be excluded from mapping.&lt;/li&gt;
&lt;li&gt;Entity Configuration: Configures entity to table and relationships mapping e.g. PrimaryKey, AlternateKey, Index, table name, one-to-one, one-to-many, many-to-many relationships etc.&lt;/li&gt;
&lt;li&gt;Property Configuration: Configures property to column mapping e.g. column name, default value, nullability, Foreignkey, data type, concurrency column etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Below attributes has been most recommeneded.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HasOne&lt;/strong&gt; method is used to configure the one side of a one to many relationship, or one end of a one to one relationship.&lt;/p&gt;
&lt;h4&gt;
  
  
  One To One Relationship
&lt;/h4&gt;

&lt;p&gt;The following example illustrates the use of HasOne with WithOne to configure a one-to-one relationship:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class SampleContext : DbContext
{
    public DbSet&amp;lt;Author&amp;gt; Authors { get; set; }

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.Entity&amp;lt;Author&amp;gt;()
            .HasOne(a =&amp;gt; a.Biography)
            .WithOne(b =&amp;gt; b.Author);
    }
}
public class Author
{
    public int AuthorId { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public AuthorBiography Biography { get; set; }
}
public class AuthorBiography
{
    public int AuthorBiographyId { get; set; }
    public string Biography { get; set; }
    public int AuthorId { get; set; }
    public Author Author { get; set; }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  One To Many Relationship
&lt;/h4&gt;

&lt;p&gt;This example illustrates the use of the HasOne method together with the WithMany method to configure a one-to-many relationship:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class SampleContext : DbContext
{
    public DbSet&amp;lt;Employee&amp;gt; Employees { get; set; }
    public DbSet&amp;lt;Company&amp;gt; Companies { get; set; }
    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.Entity&amp;lt;Employee&amp;gt;()
        .HasOne(e =&amp;gt; e.Company)
        .WithMany(c =&amp;gt; c.Employees);
    }
public class Company
{
    public int Id { get; set; }
    public string Name { get; set; }
    public ICollection&amp;lt;Employee&amp;gt; Employees { get; set; }
}
public class Employee
{
    public int Id { get; set; }
    public string Name { get; set; }
    public Company Company { get; set; }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Configure Cascade Delete using Fluent API
&lt;/h4&gt;

&lt;p&gt;Cascade delete automatically deletes the child row when the related parent row is deleted. For example, if a Grade is deleted, then all the Students in that grade should also be deleted from the database automatically.&lt;/p&gt;

&lt;p&gt;Use the OnDelete method to configure the cascade delete between Student and Grade entities, as shown below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;modelBuilder.Entity&amp;lt;Grade&amp;gt;()
    .HasMany&amp;lt;Student&amp;gt;(g =&amp;gt; g.Students)
    .WithOne(s =&amp;gt; s.Grade)
    .HasForeignKey(s =&amp;gt; s.CurrentGradeId)
    .OnDelete(DeleteBehavior.Cascade);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;OnDelete()&lt;/code&gt; method cascade delete behaviour uses the DeleteBehavior parameter. You can specify any of the following DeleteBehavior values, based on your requirement.&lt;/p&gt;

&lt;p&gt;Cascade: Dependent entities will be deleted when the principal entity is deleted.&lt;br&gt;
ClientSetNull: The values of foreign key properties in the dependent entities will be set to null.&lt;br&gt;
Restrict: Prevents Cascade delete.&lt;br&gt;
SetNull: The values of foreign key properties in the dependent entities will be set to null.&lt;/p&gt;
&lt;h4&gt;
  
  
  Fluent API HasIndex Method
&lt;/h4&gt;

&lt;p&gt;HasIndex method is used to create a database index on the column mapped to the specified entity property. By default, indexes are created for foreign keys and alternate keys. You may wish to create indexes on other properties to speed up data retrieval:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class SampleContext : DbContext
{
    public DbSet&amp;lt;Book&amp;gt; Books { get; set; }
    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.Entity&amp;lt;Book&amp;gt;()
            .HasIndex(b =&amp;gt; b.Isbn);
    }
}
public class Book
{
    public int BookId { get; set; }
    public string Title { get; set; }
    public string Isbn { get; set; }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Specifying the Maximum Length on a Property
&lt;/h4&gt;

&lt;p&gt;In the following example, the Name property should be no longer than 50 characters. If you make the value longer than 50 characters, you will get a DbEntityValidationException exception. If Code First creates a database from this model it will also set the maximum length of the Name column to 50 characters.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;modelBuilder.Entity&amp;lt;Department&amp;gt;().Property(t =&amp;gt; t.Name).HasMaxLength(50);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  The Fluent API HasColumnName Method
&lt;/h4&gt;

&lt;p&gt;The HasColumnName attribute is applied to a property to specify the database column that the property should map to when the entity's property name and the database column name differ. The following example maps the Title property in the Book entity to a database column named Description in the Books table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class SampleContext : DbContext
{
    public DbSet&amp;lt;Book&amp;gt; Books { get; set; }
    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.Entity&amp;lt;Book&amp;gt;()
            .Property(b =&amp;gt; b.Title).HasColumnName("Description");
    }
}
public class Book
{
    public int BookId { get; set; }
    public string Title { get; set; }
    public Author Author { get; set; }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>EF Core: DbContext</title>
      <dc:creator>manoj</dc:creator>
      <pubDate>Tue, 05 Oct 2021 13:34:29 +0000</pubDate>
      <link>https://dev.to/jsdevelopermano/ef-core-dbcontext-2cb6</link>
      <guid>https://dev.to/jsdevelopermano/ef-core-dbcontext-2cb6</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F19pzrahbsznzroa69pmy.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F19pzrahbsznzroa69pmy.JPG" alt="Alt Text" width="579" height="329"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The DbContext class is an integral part of Entity Framework. An instance of DbContext represents a session with the database which can be used to query and save instances of your entities to a database. DbContext is a combination of the Unit Of Work and Repository patterns.&lt;/p&gt;

&lt;p&gt;DbContext in EF Core allows us to perform following tasks:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Manage database connection&lt;/li&gt;
&lt;li&gt;Configure model &amp;amp; relationship&lt;/li&gt;
&lt;li&gt;Querying database&lt;/li&gt;
&lt;li&gt;Saving data to the database&lt;/li&gt;
&lt;li&gt;Configure change tracking&lt;/li&gt;
&lt;li&gt;Caching&lt;/li&gt;
&lt;li&gt;Transaction management&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To use DbContext in our application, we need to create the class that derives from DbContext, also known as context class. This context class typically includes DbSet properties for each entity in the model. Consider the following example of context class in EF Core.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class SchoolContext : DbContext
{
    public SchoolContext()
    {

    }

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
    }

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
    }
    //entities
    public DbSet&amp;lt;Student&amp;gt; Students { get; set; }
    public DbSet&amp;lt;Course&amp;gt; Courses { get; set; }
} 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the example above, the SchoolContext class is derived from the DbContext class and contains the DbSet properties of Student and Course type. It also overrides the OnConfiguring and OnModelCreating methods. We must create an instance of SchoolContext to connect to the database and save or retrieve Student or Course data.&lt;/p&gt;

&lt;p&gt;The OnConfiguring() method allows us to select and configure the data source to be used with a context using DbContextOptionsBuilder. Learn how to configure a DbContext class at here.&lt;/p&gt;

&lt;p&gt;The OnModelCreating() method allows us to configure the model using ModelBuilder Fluent API.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Default logging providers in ASP.NET Core</title>
      <dc:creator>manoj</dc:creator>
      <pubDate>Fri, 01 Oct 2021 17:27:48 +0000</pubDate>
      <link>https://dev.to/jsdevelopermano/default-logging-providers-in-asp-net-core-1ab9</link>
      <guid>https://dev.to/jsdevelopermano/default-logging-providers-in-asp-net-core-1ab9</guid>
      <description>&lt;p&gt;&lt;code&gt;Main()&lt;/code&gt; method in the Program class in &lt;code&gt;Program.cs&lt;/code&gt; file is the entry point for an &lt;strong&gt;asp.net&lt;/strong&gt; core application. This method calls &lt;code&gt;CreateDefaultBuilder()&lt;/code&gt; method performs several tasks like &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Setting up the web server &lt;/li&gt;
&lt;li&gt;Loading the host and application configuration from various configuration sources and 
Configuring logging&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The following is the code snippet from CreateDefaultBuilder() method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.ConfigureLogging((hostingContext, logging) =]
{
    logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
    logging.AddConsole();
    logging.AddDebug();
    logging.AddEventSourceLogger();
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As part of configuring logging, &lt;code&gt;CreateDefaultBuilder()&lt;/code&gt; method adds the following 3 logging providers by default. This is the reason when we run the asp.net core project we see the log displayed both on the console and on the debug window in Visual Studio.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Console&lt;/li&gt;
&lt;li&gt;Debug&lt;/li&gt;
&lt;li&gt;EventSource&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;CreateDefaultBuilder()&lt;/code&gt; method looks for Logging section in the application configuration file &lt;code&gt;appsettings.json&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Logging section in &lt;code&gt;appsettings.json&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The following is the Logging section in &lt;code&gt;appsettings.json&lt;/code&gt; file on my machine.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"Logging": {
  "LogLevel": {
    "Default": "Warning",
    "Microsoft": "Information"
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;LogLevel is used to control how much log data is logged or displayed.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>EF Core - Migrations</title>
      <dc:creator>manoj</dc:creator>
      <pubDate>Wed, 29 Sep 2021 16:44:29 +0000</pubDate>
      <link>https://dev.to/jsdevelopermano/ef-core-basics-5ea8</link>
      <guid>https://dev.to/jsdevelopermano/ef-core-basics-5ea8</guid>
      <description>&lt;p&gt;Step 1. Install EF Core DB Provider&lt;br&gt;
Install NuGet Package for the provider of the DB, we want to access, here we want to access MS SQL Server DB, so we need to install.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Microsoft.EntityFrameworkCore.SqlServer NuGet package&lt;/li&gt;
&lt;li&gt;Microsoft.EntityFrameworkCore.Design NuGet package&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Step 2. Install EF Core Tools&lt;br&gt;
Along with DB provider package, also need to install EF tools to execute EF Core commands.&lt;br&gt;
These make it easier to perform several EF Core-related tasks in your project at design time, such as migrations, scaffolding(demonstrate to solve problem or offering support), etc.&lt;br&gt;
Note: Migrations are a way of defining the schema(representation of a plan or theory) of your database.&lt;/p&gt;

&lt;p&gt;In order to execute EF Core commands from Package Manager Console, &lt;br&gt;
search for the Microsoft.EntityFrameworkCore.Tools package (v 5.0.9) from NuGet UI &amp;amp; install.&lt;/p&gt;

&lt;p&gt;Step 3. Create Model &amp;amp; Context Classes&lt;br&gt;
We first write the code, which means Model classes, and on the basis of these classes our tables are auto-generated inside the database.&lt;/p&gt;

&lt;p&gt;Model:&lt;/p&gt;

&lt;p&gt;Context:&lt;/p&gt;

&lt;p&gt;Step 4. Create Connection String&lt;br&gt;
To create these tables in the database we have to define our connection string where we will define our server and database name.&lt;br&gt;
Connection string you need to write inside the appsetting.json file &lt;/p&gt;

&lt;p&gt;Step 5. Install dotnet ef tool&lt;br&gt;
Open Developer PowerShell Terminal from visual studio (View → Terminal)  and run below command&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;gt;dotnet tool install --global dotnet-ef&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Step 6. Create Database using Migration&lt;br&gt;
Run the below command in Developer PowerShell Terminal  to create the initial migration script. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;gt;dotnet ef migrations add BaseMigration --context EmployeeContext&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In the above,"BaseMigration" is  descriptive name of the migration. "EmployeeContext" is context name. &lt;/p&gt;

&lt;p&gt;We have only created the migration script which is responsible for creating the database and its table. But we’ve not created the actual database and tables. So, let’s execute the migration script and generate the database and tables. Therefore, executing the migration scripts we have to execute ‘update-database’ command.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;gt;dotnet ef database update&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Step 7. Update Database using Migration&lt;br&gt;
After initial migration , you add additional fields or change existing field in your model then your model and your database are now out of sync.&lt;br&gt;
We must apply model changes to your database schema. To create a new migration run below command&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;dotnet ef migrations add AddPaymentkeyToEmployee&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In the above, "AddPaymentkeyToEmployee" is descriptive name of the migration. Note that we give migrations a descriptive name, to make it easier to understand the project history later.&lt;/p&gt;

&lt;p&gt;Since this isn't the project's first migration, EF Core now compares your updated model against a snapshot of the old model, before the column was added or modified; the model snapshot is one of the files generated by EF Core when you add a migration, and is checked into source control. Based on that comparison, EF Core detects that a column has been added, and adds the appropriate migration.&lt;br&gt;
You can now apply your migration as before:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;gt;dotnet ef database update&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Ref: &lt;a href="https://docs.microsoft.com/en-us/ef/core/" rel="noopener noreferrer"&gt;https://docs.microsoft.com/en-us/ef/core/&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>AutoMapper in C#</title>
      <dc:creator>manoj</dc:creator>
      <pubDate>Tue, 28 Sep 2021 17:14:35 +0000</pubDate>
      <link>https://dev.to/jsdevelopermano/automapper-in-c-2ifn</link>
      <guid>https://dev.to/jsdevelopermano/automapper-in-c-2ifn</guid>
      <description>&lt;p&gt;AutoMapper in C# is a mapper between two objects. That is AutoMapper is an object-object mapper. It maps the properties of two different objects by transforming the input object of one type to the output object of another type.&lt;/p&gt;

&lt;p&gt;It also provides some interesting facts to take the dirty work out of figuring out how to map an object of type A with an object of type B as long as the object of type B follows AutoMapper’s established convention.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let’s discuss the step-by-step procedure to use AutoMapper in C#.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  1: Installing the AutoMapper library
&lt;/h3&gt;

&lt;p&gt;The AutoMapper is an open-source library present in &lt;a href="https://github.com/AutoMapper" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;. To install this library, open the Package Manager Console window and then type the following command and press enter key to install the AutoMapper library in your project:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&amp;gt; Install-Package AutoMapper&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once you installed the AutoMapper library, then it will add a reference to the AutoMapper dll which you can find in the project references section as shown in the below image.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2zhwtgwy9r6s4dk2punm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2zhwtgwy9r6s4dk2punm.png" alt="Alt Text" width="320" height="238"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2: Initializing or Configuring the AutoMapper
&lt;/h3&gt;

&lt;p&gt;Once you have defines your types (i.e. classes) then you can create a mapper for the two types using the constructor of MapperConfiguration class. You can create only one MapperConfiguration instance per AppDomain and should be instantiated during the application start-up. The syntax to create the MapperConfiguration instance is given below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Initialize the mapper
  var config = new MapperConfiguration(cfg =&amp;gt;
               cfg.CreateMap&amp;lt;Employee, EmployeeDTO&amp;gt;()
            );
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The type on the left is the source type i.e. TSource, in our example, it will be going to Employee object, and the type on the right is the destination type i.e. TDestination, in our example, it will be going to EmployeeDTO object. So, two maps the Employee with EmployeeDTO, you need to create the mapper configuration.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using System;
using AutoMapper;
namespace AutoMapperDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            //Initialize the mapper
            var config = new MapperConfiguration(cfg =&amp;gt;
                    cfg.CreateMap&amp;lt;Employee, EmployeeDTO&amp;gt;()
                );

            //Creating the source object
            Employee emp = new Employee
            {
                Name = "James",
                Salary = 20000,
                Address = "London",
                Department = "IT"
            };

            //Using automapper
            var mapper = new Mapper(config);
            var empDTO = mapper.Map&amp;lt;EmployeeDTO&amp;gt;(emp);
            //OR
            //var empDTO2 = mapper.Map&amp;lt;Employee, EmployeeDTO&amp;gt;(emp);

            Console.WriteLine("Name:" + empDTO.Name + ", Salary:" + empDTO.Salary + ", Address:" + empDTO.Address + ", Department:" + empDTO.Department);
            Console.ReadLine();
        }
    }

    public class Employee
    {
        public string Name { get; set; }
        public int Salary { get; set; }
        public string Address { get; set; }
        public string Department { get; set; }
    }

    public class EmployeeDTO
    {
        public string Name { get; set; }
        public int Salary { get; set; }
        public string Address { get; set; }
        public string Department { get; set; }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ref: &lt;a href="https://dotnettutorials.net/lesson/automapper-in-c-sharp/" rel="noopener noreferrer"&gt;https://dotnettutorials.net/lesson/automapper-in-c-sharp/&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
