- Update in Dto
- Update in Main Table
- Add Scalar Property in Edmx Table
- Open Edmx in xml format and add the property
- Then go to table mappings and map the added field
Thursday, February 6, 2025
Process for updating Edmx on Entity Framework
Monday, September 9, 2024
Monday, August 19, 2024
Class/Record/Struct
| Feature | Class | Record | Struct |
|---|---|---|---|
| Type | Reference Type | Reference Type (since C# 10, can be record struct) | Value Type |
| Memory Allocation | Typically allocated on the heap. | Typically allocated on the heap. | Typically allocated on the stack (or heap if used as part of a class or array) |
| Default Constructor | Can have a parameterless constructor, and can be explicitly defined. | Implicit parameterless constructor is not allowed; parameters are required. | Parameterless constructor is provided by default and initializes all fields to default values. |
| Inheritance | Supports inheritance (can inherit from other classes and be inherited). | Supports inheritance (can inherit from other records but not from classes). | Does not support inheritance (cannot inherit from or be inherited by other types). |
| Equality | Uses reference equality by default, can override Equals and GetHashCode for value-based equality. | Uses value-based equality by default (based on all properties). Automatically implements Equals, GetHashCode, and ToString. | Uses value-based equality by default (based on all fields). Automatically implements Equals, GetHashCode, and ToString. |
| Mutability | Mutable by default; properties can be changed after object creation. | Immutable by default; properties are readonly and set via constructor. | Immutable by default (properties are typically readonly and initialized in the constructor). |
| Deconstruction | Not supported by default. | Supports deconstruction with tuple-like syntax. | Supports deconstruction with tuple-like syntax. |
| Constructor | Can have multiple constructors with various parameters. | Primary constructor is defined with positional parameters; can also have additional constructors. | Constructor must initialize all fields; no parameterless constructor allowed unless provided by the compiler. |
| Default Values | Fields initialized to default values if not explicitly set. | Properties are initialized via the constructor. | Fields are initialized to default values (e.g., 0, null). |
| Use Cases | Used for complex objects with behavior and mutable state. | Ideal for immutable data models, DTOs, and scenarios where value-based equality is important. | Ideal for lightweight, immutable data structures where copying and stack allocation are beneficial. |
Friday, May 17, 2024
Angular Basics
Intro
• package.json
• (list
of dependencies)
• package-lock.json
• (details
list of that dependencies)
• angular.json
• (map
everything here: assets, scripts etc)
• tsconfig.json
• (typescript
configuration file)
• polyfills.ts
• (compatibility
file)
Components
• Modules
must be declared in the imports
• Components
must be declared in the declarations
• Standalone
components are not dependent in any modules and it must be declared in imports
• and Pipes are doing the transformation over text
Bindings - Two Way, Property, Event
Routing
• Basic
Routing
• Routes – for mapping path
& component
• routerLink – navigate to
different routes
• router-outlet– for displaying
matched route
• Child
routing
• Activated
Route (const routeId = route.snapshot.paramMap.get(‘id’);)
• Module
Routing
• const
routes : Routes
• Lazy
Loading
• Load when required (loadChildren then import)
Directives
• Add
additional behavior to elements
• Components
works as a directive
• Attribute
Directive
ngClass (Binding
Classes)
ngStyle (Binding
Styles, Only accept objects s = {})
ngModel (Two Way
Binding)
• Structural
Directive
*ngIf
*ngFor
*ngSwitch
Services
• Defined
with @Injectable
• All
are in observable format and without subscribe it won’t
work (Rxjs feature)
FormType
• TDF
–
handle in html file
• ngForm
• Reactive
–
handle in ts file
• FormGroup
Guard
• used
to control access in particular route
• canActivate
• canActivateChild
• canDeactivate
• canLoad
Interceptor
• Used
for token login
• Declares in app.module [Providers]
Rxjs
• Observable and Operators
• Promise (then, then, finally)
Monday, March 4, 2024
Reactive Programming
Pending: Initial state, neither fulfilled nor rejected.
Fulfilled: The operation completed successfully.
Rejected: The operation failed.
from function to convert various data sources, including Promises, into Observables. toPromise() operator to convert an Observable into a Promise.Saturday, June 10, 2023
Run React Globally
If you have problems running create-react-app in text editors but the package is installed globally. So here is the SOLUTION-------------
Open PowerShell as an administrator. You can do this by right-clicking on the Windows Start button and selecting "Windows PowerShell (Admin)".
In the PowerShell window, run the following command to check the current execution policy:
powershellGet-ExecutionPolicyThe output will be one of the following:
- Restricted: This means that script execution is disabled. You need to change it to a more permissive policy.
- AllSigned or RemoteSigned: These policies allow script execution but require digitally signed scripts. If you encounter this, you can skip changing the execution policy and try using the
npx create-react-appcommand instead ofcreate-react-app.
To change the execution policy to allow script execution, run the following command:
powershellSet-ExecutionPolicy UnrestrictedYou will be prompted to confirm the change. Type
Yand press Enter.After changing the execution policy, you should be able to use the
create-react-appcommand without encountering the "running scripts is disabled" error.Once you've finished using
create-react-app, it's recommended to set the execution policy back to a more secure value. Run the following command:powershellSet-ExecutionPolicy Restricted
By following these steps, you should be able to resolve the script execution error and use create-react-app globally in any text editor.
Sunday, May 7, 2023
Logical Shifting COA
Thursday, March 2, 2023
How to Absorb Books
- [1] Flip through each page
- [2] End of chapter-looking for question
- [3] Read the bold prints
- [4] First and last sentence of each paragraph
- [5] Then start reading
Tuesday, January 3, 2023
Saturday, September 24, 2022
Microprocessor, Microcontroller & Embedded Systems
A microcontroller is a small computer on a single integrated circuit chip. A microcontroller typically contains one or more processor cores, along with additional peripherals (memory, serial interface, timer, programmable I/O peripherals, etc.) on the same chip.
A microprocessor is a computer processor that incorporates the functions of a central processing unit (CPU) onto just a few (and often only one) integrated circuits.
Microprocessor and Microcontroller Architecture Explained
Microprocessors and microcontrollers perform relatively similar functions, but if we look specifically at the architecture of each type of chip, we'll see just how different they are.
The defining characteristic of a microcontroller is that it incorporates all of the necessary computing components onto a single chip. The CPU, memory, interrupt controls, timer, serial ports, bus controls, I/O peripheral ports, and any other necessary components are all present on the same chip and no external circuits are required.
In contrast, a microprocessor consists of a CPU and several supporting chips that supply the memory, serial interface, inputs and outputs, timers, and other necessary components. Many sources indicate that the terms "microprocessor" and "CPU" are essentially synonymous, but you may also come across microprocessor architectural diagrams that depict the CPU as a component of the microprocessor. You can think of a microprocessor as a single integrated circuit chip that contains a CPU. That chip can connect to other external peripherals such as a control bus or data bus that provide binary data inputs and receive outputs from the microprocessor (also in binary).
The key difference here is that microcontrollers are self-contained. All of the necessary computing peripherals are internal to the chip, where microprocessors deal with external peripherals. As we'll soon see, each of these architectures has its own unique advantages and disadvantages.
Microprocessor and Microcontroller Applications Explained
Microprocessors and microcontrollers are both ways of implementing CPUs in computing. So far we've learned that microcontrollers integrate the CPU onto the chip with several other peripherals, while a microprocessor consists of a CPU with wired connections to other supporting chips. While there may be some overlap, microprocessors and microcontrollers have relatively separate and distinct applications.
Microprocessors depend on interfacing a number of additional chips to form a microcomputer system. They are often used in personal computers where users require powerful, high-speed processors with versatile capabilities that support a range of computing applications. The use of external peripherals with microprocessors means that components can be upgraded easily - for example, a user might replace their RAM chip to benefit from additional memory.
Programmable microcontrollers contain all of the components of a microcomputer system on a single chip that runs at low power and performs a dedicated operation. Microcontrollers are most commonly used in embedded systems applications where devices are expected to execute basic functions reliably and without human interference for extended periods of time.
Three Key Differences Between Microcontrollers and Microprocessors
Cost
Generally speaking, microcontrollers tend to cost less than microprocessors. Microprocessors are typically manufactured for use with more expensive devices that will leverage external peripherals to drive performance. They are also significantly more complex, as they are meant to perform a variety of computational tasks while microcontrollers usually perform a dedicated function. This is another reason why microprocessors require a robust external memory source - to support more complex computational tasks.
With a microcontroller, engineers write and compile the code intended for the specific application and upload it into the microcontroller, which internally houses all of the necessary computing features and components to execute the code. Due to their narrow individual applications, microcontrollers frequently require less memory, less computing power, and less overall complexity than microprocessors, hence the lower cost.
Speed
When it comes to overall clock speed, there is a significant difference between industry-leading microprocessor chips and high-quality microcontrollers. This relates back to the idea that microcontrollers are meant to handle a specific task or application, while a microprocessor is meant for more complex, robust, and unpredictable computing tasks.
One of the key design advantages associated with microcontrollers is that they can be optimized to run the code for a specific task. That means using just the right amount of speed and power to get the job done - no more and no less. As a result, many microprocessors are clocking speeds of up to 4 GHz while microcontrollers can operate with much lower speeds of 200 MHz or less.
At the same time, the close proximity of on-chip components can help microcontrollers perform functions quickly despite their slower clock speed. Microprocessors can sometimes operate more slowly because of their dependence on communicating with external peripherals.
Power Consumption
One of the key advantages associated with microcontrollers is their low power consumption. A computer processor that performs a dedicated task requires less speed, and therefore less power, than a processor with robust computational capacity. Power consumption plays an important role in implementation design: a processor that consumes a lot of power may need to be plugged in or supported by an external power supply, whereas a processor that consumes limited power could be powered for a long time by just a small battery.
For tasks that require low computational power, it can be much more cost effective to implement a microcontroller versus a microprocessor that consumes much more power for the same output.
Embedded Systems and Microcontrollers
Microcontrollers include many features that make them suitable for application in embedded systems:
- They are self-contained, including all of the necessary peripherals on a single integrated circuit chip
- They are designed to run a single dedicated application
- They can be optimized (software and hardware) for a single dedicated application
- They exhibit low power consumption and may include power-saving features, making them ideal for applications that require the processor to function for long periods of time without human interference
- They are relatively inexpensive when compared to CPUs, mainly because the entire system exists on a single chip
While microprocessors may be more powerful, that additional power comes at a cost that makes microprocessors less desirable for embedded systems applications: larger size, more power consumption, and greater cost.
How Do Embedded Systems Work?
An embedded system is a hardware-and-software system that performs a dedicated function within a larger mechanical or electrical system. Embedded systems are typically designed to deal with real-time computing constraints, and are controlled by a real-time operating system (RTOS) that can process data as soon as it is received without buffer delays. Most embedded systems today are based on programmable microcontrollers, small computers with integrated memory housed on a single integrated circuit. We can think of embedded systems as having three main components: the hardware component, the software component, and the real-time operating system.
Embedded Systems Hardware
Embedded systems are small embedded computers that live inside other mechanical or electrical systems. Embedded systems can be programmed to fulfill a variety of functions, but each one must include the basic components of a computer:
- Processor - Embedded systems are built around a microprocessor or microcontroller. Microcontrollers include one or more processors (CPUs), along with integrated memory and programmable input/output peripherals. Most automatically controlled products or devices use microcontrollers , including office machines, power tools, and automobile engine control systems.
- Power Supply - Embedded systems have significantly lower power requirements than a standard computer due to their small size and comparatively low processing power. Embedded engineers should choose a power supply that offers a stable and smooth output of power to the microcontroller with adequate output current to drive the load and stable performance in a variety of environments.
- Memory - If an embedded system is powered by a microcontroller, the system's memory is already available on the chip. If using a microprocessor, a memory chip should be added to the system. Embedded systems use read-only memory (ROM) to store the software program used to operate the microcontroller and random access memory (RAM) to temporarily store data that is received or in-use by the system.
- Communication Ports - Embedded systems use wired communications to transmit data between the microcontroller, peripheral devices, and other embedded systems. Engineers must select a communication protocol to facilitate this data exchange, ensuring that devices in the system are all "speaking the same language" when they communicate or transmit data. Common communication protocols for embedded systems include the I2C protocol, SPI protocol, and the USB protocol, but there are many other wired and wireless protocols available for engineers to choose from.
Embedded Systems Software and RTOS
Programming for embedded systems is most frequently done using C, C++, the Embedded C language or assembly language. The software programming for embedded systems, including the RTOS, resides in the memory chip and can be accessed whenever the power supply for the system is activated. Unlike standard computers, embedded systems are designed to carry out a specific task or function rather than for "general use". As such, embedded systems software is highly specific to each application of embedded systems.
Embedded Systems Applications Today
Embedded systems impact everyday life in so many ways, we may not always realize the number of devices in our immediate surroundings that are controlled by embedded systems. Let's take a brief inventory of some of the most important embedded systems applications and areas of innovation today.
Embedded Systems in Communications
Cellular phones are some of the most accessible examples of embedded systems that we interact with on a daily basis. Mobile phones contain all of the characteristic components of an embedded system: a power supply, some memory or storage, a processor, and ports for communicating with other devices. Mobile phones also contain additional hardware that supports utilities like audio, cameras, internet connectivity, touch screen and calling.
Like other embedded systems, your mobile phone uses a defined communication protocol to facilitate data transactions between the microcontroller or processor and peripheral devices that collect data.
Embedded Systems in Consumer Electronics
Embedded systems are finding their way into many categories of consumer electronics, including home security systems, home appliances, printers, watches, and more. Home appliances like refrigerators, microwave ovens and washing machines use simple embedded systems to provide features, collect input from users, and control the appliance according to user specifications. They may even use some sensors to collect information about how the appliance is functioning and modify settings accordingly.
Home security systems use embedded systems with peripheral sensors to collect information about activity in and around the home and either initiate a response (alarm) or communicate that data to the homeowner.
Embedded Systems in Automotive Applications
All cars manufactured today contain at least one computer that works to measure and minimize engine emissions throughout the operational life of the vehicle. This embedded computer collects data from a variety of peripheral sensor devices, including oxygen sensors, air pressure sensors, air temperature sensors, and the engine temperature sensor. The computer can use data from these sensors to measure the cleanliness of engine emissions and control the fuel injectors, spark plugs and other variables to optimize for engine performance while minimizing environmental impact.
Most vehicles have additional embedded systems that control things like automatic transmission, anti-lock braking systems, air bags, key-less entry or security systems, audio devices and safety applications like lane drift detection.
Embedded Systems in Healthcare
Embedded systems are used in medical scanning machines, imaging systems, and diagnostic equipment. Some of the most commonly used medical imaging devices, such as CT scanners, MRI machines, and Sonography equipment used to conduct ultrasound imaging are built around and controlled by embedded systems. Digital flow sensors used to monitor respiration, heart monitoring machines, and simple diagnostic machines that test for blood pressure or glucose content also use embedded systems.
The expansion of the Internet of Things (IoT) is leading to new trends in embedded systems for healthcare. In the future, patients will use wearable devices to track their vital signs with data regularly transmitted to their hospital or physician in real time. There will be no shortage of product development opportunities for embedded systems engineers that can use their skills to lower healthcare costs or improve access for patients.
The Future of Embedded Systems
Embedded systems are a major area of innovation that is expected to grow substantially on a per-year basis. Across industries, embedded systems engineers are deploying new products and technologies to increase safety and reduce costs.
In the automotive sector, we're seeing major technological growth in embedded systems as major manufacturers partner with leading technology companies to develop self-driving vehicles. The market for wearable medical devices is expanding rapidly, with an estimated growth rate of 18.5% through 2023. There is also a growing demand for "smart" home appliances and devices that can reduce energy consumption while offering convenience and features for homeowners.
Summary
The growing demand for "smart" devices across industries is creating a major area of opportunity for embedded systems engineers to develop their capabilities and launch new products. Embedded systems consist of a microcontroller with on-board memory, a power supply, and communication ports for transmitting data to other devices. Embedded software programs tell the microcontroller how to respond in real time to data collected from the environment through peripheral sensors and devices. Embedded systems are used to enhance safety, reduce costs, and offer convenience and cost-savings to customers in industries that include automotive, home/consumer electronics, communications, and healthcare.
Differences Between Arduino and Raspberry Pi
| No. | Arduino | Raspberry Pi |
|---|---|---|
| 1. | Control unit of Arduino is from Atmega family. | While control unit of Raspberry Pi is from ARM family. |
| 2. | Arduino is based on a microcontroller. | While Raspberry Pi is based on a microprocessor. |
| 3. | It is designed to control the electrical components connected to the circuit board in a system. | While Raspberry Pi computes data and produces valuable outputs, and controls components in a system based on the outcome of its computation. |
| 4. | Arduino boards have a simple hardware and software structure. | While Raspberry Pi boards have a complex architecture of hardware and software. |
| 5. | CPU architecture: 8 bit. | CPU architecture: 64 bit. |
| 6. | It uses very less RAM, 2 kB. | While Raspberry Pi requires more RAM, 1 GB. |
| 7. | It clocks a processing speed of 16 MHz. | While Raspberry Pi clocks a processing speed of 1.4 GHz. |
| 8. | It is cheaper in cost. | While Raspberry Pi is expensive. |
| 9. | It has a higher I/O current drive strength. | While Raspberry Pi has a lower I/O current drive strength. |
| 10. | It consumes about 200 MW of power. | While it consumes about 700 MW of power. |
| 11. | Its logic level is 5V. | Its logic level is 3V. |
| 12. | It does not have internet support. | It has inbuilt Ethernet port and WiFi support. |
| 13. | It has higher current drive strength. | It has lower current drive strength. |
| 14. | Some of the applications of Arduino are traffic light countdown timer , Weighing machines , etc. | Some of the application of Raspberry Pi are Stop motion cameras , Robot Controllers , Game Servers. |