var - local variable type inference (it can just declare something all right).
$ - embed expressions or variables directly inside a string
constructor - A constructor is a method called by the runtime when an instance of a
class or a struct is created.
Encapsulation - Encapsulation is the concept of wrapping data (variables) and
methods (functions) that operate on the data into a single unit (class), and
restricting direct access to some of the object’s components.
Inheritance - Inheritance is a mechanism in which one class acquires the properties
(fields) and behaviors (methods) of another class.
Interfaces - An interface is a reference type in C# that defines a set of abstract
members (methods, properties, events, or indexers) that must be implemented by a
class or a struct.
Records - A record is a type that provides built-in value equality, immutability,
and concise syntax for defining objects that hold data.
Value-based equality: Two record objects are equal if their values are equal.
Immutability: Records are immutable by default, which means their values can’t
change after creation (but you can make mutable ones).
With-expression: Allows copying a record with changes to specific properties.
Deconstruction: You can deconstruct record values into individual variables.
Objects - An object is basically a block of memory that has been allocated and
configured according to the blueprint.
Polymorphism - Polymorphism means "many forms."
It allows objects of different types to be treated as objects of a common base
type, usually through inheritance.
Types of Polymorphism in C#:
Compile-time (Static): Achieved through method overloading and operator
overloading.
Run-time (Dynamic): Achieved through method overriding using virtual and override.
Tuple - A tuple is a data structure in C# that allows you to store a fixed-size
collection of elements, each potentially of a different type.
Task asynchronous programming (TAP)
DATEADD(MINUTE, 330, GETUTCDATE()) - add this procedures exact time
Format Date & Time :-
CAST(FORMAT([Link], 'dd-MM-yyyy') AS varchar(10)) AS [Date],
CAST(FORMAT([Link], 'hh:mm tt') AS varchar(10)) AS [Time]
FORMAT(@FromDate, 'dd-MM-yyyy') -- format Date dd-MM-yyyy
Why use DISTINCT?
If multiple employees have the same salary, DISTINCT ensures we don’t count the
same amount multiple times.
COALESCE([Link], '') + ' ' + COALESCE([Link], '') AS VendorFullName -- map
complete name
select CAST (effectiveDateForm as DATE),max(id) from SalonServices
group by CAST (effectiveDateForm as DATE) having count(CAST (effectiveDateForm as
DATE))>1
--delete SalonServices where id in (
--select max(id) from SalonServices
--group by CAST (effectiveDateForm as DATE) having count(CAST (effectiveDateForm as
DATE))>1
--)
handling nullable DateTime values -
if ([Link])
fromDate = [Link];
if ([Link])
toDate = [Link](1).AddTicks(-1);
Add column:-
ALTER TABLE InventoryTransactionIssueItem
Add ToIssueId INT
Drop column:-
ALTER TABLE InventoryTransactionAudit
DROP COLUMN ToIssueId;
Add a typeid in table MasterPrerequisites and file name is PostDeployment:-
IF (NOT EXISTS(SELECT 1 FROM MasterPrerequisites Where [optionid] =3 AND
[settingid]=6 AND [option] = 'DashBoard'))
BEGIN
INSERT [dbo].[MasterPrerequisites] ( [settingid], [setting], [optionid],
[option], [isactive]) VALUES ( 6, 'NoteType', 3, 'DashBoard', 1)
END
delete row wise data : -
delete from InventoryTransactionIssue
where id in (19,20,21)
CASE
WHEN [Link] IS NULL THEN NULL
ELSE FORMAT([Link], 'dd-MM-yyyy')
END AS DeliveryDate
GET and POST API Format -
POST API CONTROLLER -
[HttpPost("attendance")]
public async Task<ActionResult> Attendance(List<AttendanceRequest> requests)
{
var response = new ResponseModel();
try
{
foreach (var request in requests) {
if (![Link])
{
[Link] = false;
[Link] = "Invalid Model State";
[Link] = ModelState;
return BadRequest(response);
}
response = await _attendanceRegisterService.SaveAttendance(request);
}
return Ok(response);
}
catch (Exception ex)
{
_logger.Log([Link], [Link], requests);
[Link] = false;
[Link] = [Link];
return BadRequest(response);
}
}
GET API CONTROLLER -
[HttpGet("GetInventoryTransactionIssue")]
public async Task<IActionResult> GetInventoryTransactionIssue([FromQuery]
GetInventoryTransactionIssueRequest request)
{
var response = new ResponseModel();
try
{
if ([Link]([Link]))
throw new ArgumentNullException(nameof([Link]));
ValidateGuid([Link]);
response = await
_inventoryLocationService.GetInventoryTransactionIssue(request);
return Ok(response);
}
catch (Exception ex)
{
[Link] = false;
[Link] = [Link];
return BadRequest(response);
}
}
BeginTransaction():-
Starts a new transaction.
After this, multiple operations (INSERT, UPDATE, DELETE) can be executed as one
single unit.
These changes are not saved to the database until you commit.
EndTransaction():- (usually Commit() or Rollback())
Commit() saves all the changes permanently.
Rollback() undoes all changes made after BeginTransaction().
fnGetDocumentNumber :-Document ya Voucher ke liye ek unique, auto-incrementing
number generate karna.
Genetate a new voucherno.:-
SET @TransactionVoucherNumber =
[Link]('GetNumber',@SalonReferenceId,@TransactiontyperefrenceId );
UPDATE TransactionNumberMaster SET
RunningSequenceNumber=RunningSequenceNumber+1,LastNumberUsed=RunningSequenceNumber
WHERE TransactionTypeId=@TransactionId
PRINT @TransactionVoucherNumber;
If i want change a table name and column name without drop table and column then
run this query :-
EXEC sp_rename 'InventoryTransactionIssueItem', 'InventoryTransactionChild';
EXEC sp_rename '[Link]',
'InventoryTransactionId', 'COLUMN';
Declare @JsonResponse Nvarchar(Max)
Set @JsonResponse = ()
If(@JsonResponse Is Null OR LEN(@JsonResponse) = 0)
Begin
Select Convert(Bit, 0) As Status, Null As JsonData, 'No Data Found' As
Message
End
Else
Begin
Select Convert(Bit, 1) As Status, @JsonResponse As JsonData, 'Data
Found' As Message
End
select Count(*),SalonProductId from SalonProductMoreDetail
group by SalonProductId having count(*) > 1
order by SalonProductId