Tuesday, January 23, 2024

How to save List of object to database with XML

 public void SaveAllActSectionDetailsList(long referenceId, long referenceType, List<ActSectionDetailsDTO> actSectionDetailsList)

        {

            actSectionDetailsList.ForEach(t => { t.ReferenceId = referenceId; t.ReferenceType= referenceType; });

            using (var actSectionDetailsClient = ServiceClient<IActSectionDetailsManager>.Create(ObjectConstants.ActSectionDetailsManager))

            {

                actSectionDetailsClient.Instance.InsertUpdateActSectionDetailsList(new ActSectionDetailsDTO { ActSectionDetailsList = actSectionDetailsList });

            }

        }


---------------  Entity ------------------


Initializes a new instance of the <see cref="ActSectionDetailsDTO"/> class.

        /// </summary>

        public ActSectionDetailsDTO()

        {

            ActSectionDetailsList = new List<ActSectionDetailsDTO>();

        }


        /// <summary>

        /// Gets or sets the act section details list.

        /// </summary>

        /// <value>The act section details list.</value>

        [XmlElement(ElementName = "ActSectionDetailsList")]

        public List<ActSectionDetailsDTO> ActSectionDetailsList { get; set; }


Monday, January 22, 2024

Stored procedure for Insert and Update with XML and List of Object (Multiple ) From code C#

USE [SBI]

GO

/****** Object:  StoredProcedure [dbo].[IUSP_DocumentList]    Script Date: 1/22/2024 3:12:34 PM ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO



ALTER PROCEDURE [dbo].[IUSP_DocumentList]

(

@xmlDoc xml

)

AS

BEGIN 

SET ARITHABORT ON 

DECLARE @TranName NVARCHAR(255)

DECLARE @ErrMsg NVARCHAR(2048)

DECLARE @ErrSeverity INT;

DECLARE @intPointer INT;

SET @ErrSeverity = 15; 


BEGIN TRY


EXEC sp_xml_preparedocument @intpointer OUTPUT,@xmlDoc

        DECLARE @DocumentId bigint

Friday, January 19, 2024

ASP.NET properties with viewstate and session of List - Viewstate property

  public List<CourtApplicationProceedingsDTO> ProceedingList

        {

            get { return (Session["CourtApplicationProceedings"] != null ? (List<CourtApplicationProceedingsDTO>)Session["CourtApplicationProceedings"] : new List<CourtApplicationProceedingsDTO>()); }

            set { Session["CourtApplicationProceedings"] = value; }

        }


        public long DatesId

        {

            get { return Convert.ToInt64(ViewState["DatesId"]); }

            set { ViewState["DatesId"] = value; }

        }

Wednesday, January 17, 2024

Flow to Create and Drop Tables Primary Key Foreign Key relationship tables

 > When deleting the tables, First delete foreign key tables. At last delete the primary key tables that has relationship with other tables (Foreign key tables)

When creating

> First create primary key table and then create foreign key tables.