Skip to content

Commit 81e0521

Browse files
Merge branch '949122-postgresql-hf' of https://github.com/syncfusion-content/ej2-asp-core-mvc-docs into 949122-postgresql-hf
# Conflicts: # ej2-asp-mvc-toc.html
2 parents 4f7ac0d + 7af7a2c commit 81e0521

File tree

2 files changed

+35
-39
lines changed

2 files changed

+35
-39
lines changed

ej2-asp-core-mvc/grid/EJ2_ASP.MVC/connecting-to-database/postgresql-server.md

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ namespace MyWebService.Controllers
8484
[HttpGet]
8585
private List<Orders> GetOrderData()
8686
{
87-
// Define the SQL query to fetch all orders from the "Orders" table, ordered by OrderID.
87+
// Define the SQL query to fetch all orders from the orders table, ordered by OrderID.
8888
string query = "SELECT * FROM public.\"Orders\" ORDER BY \"OrderID\"";
8989

9090
// Establish a connection to the PostgreSQL database using the connection string.
@@ -235,7 +235,7 @@ Now, add the Syncfusion ASP.NET MVC Grid tag helper in `~/Views/Home/Index.cshtm
235235
{% tabs %}
236236
{% highlight cshtml tabtitle="Index.cshtml" %}
237237

238-
// Replace xxxx with your actual port number
238+
// Replace xxxx with your actual port number.
239239
@Html.EJS().Grid("Grid").DataSource(ds => ds.Url("https://localhost:xxxx/api/Grid").Adaptor("UrlAdaptor")).Columns(col =>
240240
{
241241
col.Field("OrderID").HeaderText("Order ID").Width("100").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
@@ -281,7 +281,7 @@ public class GridController : ApiController
281281
[HttpGet]
282282
private List<Orders> GetOrderData()
283283
{
284-
// Define the SQL query to fetch all orders from the "Orders" table, ordered by OrderID.
284+
// Define the SQL query to fetch all orders from the orders table, ordered by OrderID.
285285
string query = "SELECT * FROM public.\"Orders\" ORDER BY \"OrderID\"";
286286

287287
// Establish a connection to the PostgreSQL database using the connection string.
@@ -566,7 +566,7 @@ public object Post(DataManagerRequest DataManagerRequest)
566566

567567
### Handling CRUD operations
568568

569-
The Syncfusion ASP.NET MVC Grid seamlessly integrates CRUD (Create, Read, Update and Delete) operations with server-side controller actions through specific properties: `InsertUrl`, `RemoveUrl`, `UpdateUrl`,`CrudUrl`, and `BatchUrl`. These properties enable the Grid to communicate with the data service for every Grid action, facilitating server-side operations.
569+
The Syncfusion ASP.NET MVC Grid seamlessly integrates CRUD (Create, Read, Update and Delete) operations with server-side controller actions through specific properties: `InsertUrl`, `RemoveUrl`, `UpdateUrl` and `BatchUrl`. These properties enable the Grid to communicate with the data service for every Grid action, facilitating server-side operations.
570570

571571
**CRUD Operations Mapping**
572572

@@ -575,10 +575,9 @@ The following properties enable the Grid to interact with API endpoints for diff
575575
1. **InsertUrl**: Specifies the URL for inserting new data.
576576
2. **RemoveUrl**: Specifies the URL for removing existing data.
577577
3. **UpdateUrl**: Specifies the URL for updating existing data.
578-
4. **CrudUrl**: Specifies a single URL for all CRUD operations.
579-
5. **BatchUrl**: Specifies the URL for batch editing.
578+
4. **BatchUrl**: Specifies the URL for batch editing.
580579

581-
To enable editing in ASP.NET MVC Grid, refer to the editing [Documentation](https://ej2.syncfusion.com/aspnetmvc/documentation/grid/editing/edit). In the below example, the inline edit `Mode` is enabled and [Toolbar](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_Toolbar) property is configured to display toolbar items for editing purposes.
580+
To enable editing in ASP.NET MVC Grid, refer to the editing [documentation](https://ej2.syncfusion.com/aspnetmvc/documentation/grid/editing/edit). In the below example, the inline edit `Mode` is enabled and [Toolbar](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_Toolbar) property is configured to display toolbar items for editing purposes.
582581
583582
{% tabs %}
584583
{% highlight cshtml tabtitle="Index.cshtml" %}
@@ -626,7 +625,7 @@ To insert a new row, simply click the **Add** toolbar button. The new record edi
626625
{% highlight cs tabtitle="GridController.cs" %}
627626

628627
/// <summary>
629-
/// Inserts a new order record into the "Orders" table in the PostgreSQL database.
628+
/// Inserts a new order record into the orders table in the PostgreSQL database.
630629
/// </summary>
631630
/// <param name="value">The CRUDModel containing the order details to be inserted.</param>
632631
/// <returns>Returns an HTTP response indicating success or failure.</returns>
@@ -677,7 +676,7 @@ To edit a row, first select desired row and click the **Edit** toolbar button. T
677676
{% highlight cs tabtitle="GridController.cs" %}
678677

679678
/// <summary>
680-
/// Updates an existing order record in the "Orders" table in the PostgreSQL database.
679+
/// Updates an existing order record in the orders table in the PostgreSQL database.
681680
/// </summary>
682681
/// <param name="value">The CRUDModel containing the updated order details.</param>
683682
/// <returns>Returns an HTTP response indicating success or failure.</returns>
@@ -729,7 +728,7 @@ To delete a row, simply select the desired row and click the **Delete** toolbar
729728
{% highlight cs tabtitle="GridController.cs" %}
730729

731730
/// <summary>
732-
/// Deletes an order record from the "Orders" table in the PostgreSQL database.
731+
/// Deletes an order record from the orders table in the PostgreSQL database.
733732
/// </summary>
734733
/// <param name="value">The CRUDModel containing the OrderID of the record to be deleted.</param>
735734
/// <returns>Returns an HTTP response indicating success or failure.</returns>
@@ -747,7 +746,7 @@ public IHttpActionResult Remove(CRUDModel<Orders> value)
747746
// Open the database connection.
748747
Connection.Open();
749748

750-
// Define an SQL query to delete a record from the "Orders" table where OrderID matches.
749+
// Define an SQL query to delete a record from the orders table where OrderID matches.
751750
string queryStr = "DELETE FROM \"Orders\" WHERE \"OrderID\"=@OrderID";
752751

753752
// Create a command object to execute the delete query.
@@ -776,7 +775,7 @@ To perform batch operation, define the edit `Mode` as **Batch** and specify the
776775
{% highlight cs tabtitle="GridController.cs" %}
777776

778777
/// <summary>
779-
/// Performs batch update operations (insert, update, and delete) on the "Orders" table in a single transaction.
778+
/// Performs batch update operations (insert, update, and delete) on the orders table in a single transaction.
780779
/// </summary>
781780
/// <param name="value">The CRUDModel containing lists of added, changed, and deleted order records.</param>
782781
/// <returns>Returns an HTTP response indicating the success or failure of the batch operation.</returns>
@@ -796,7 +795,7 @@ public IHttpActionResult BatchUpdate(CRUDModel<Orders> value)
796795
// Process the list of updated records.
797796
if (value.changed != null && value.changed.Count > 0)
798797
{
799-
// Define an SQL query to update records in the "Orders" table.
798+
// Define an SQL query to update records in the orders table.
800799
string updateQuery = "UPDATE \"Orders\" SET \"CustomerID\"=@CustomerID, \"Freight\"=@Freight, \"EmployeeID\"=@EmployeeID, \"ShipCity\"=@ShipCity WHERE \"OrderID\"=@OrderID";
801800

802801
// Create a command object to execute the update query within the transaction.
@@ -824,7 +823,7 @@ public IHttpActionResult BatchUpdate(CRUDModel<Orders> value)
824823
// Process the list of newly added records.
825824
if (value.added != null && value.added.Count > 0)
826825
{
827-
// Define an SQL query to insert new records into the "Orders" table.
826+
// Define an SQL query to insert new records into the orders table.
828827
string insertQuery = "INSERT INTO \"Orders\" (\"CustomerID\", \"Freight\", \"ShipCity\", \"EmployeeID\") VALUES (@CustomerID, @Freight, @ShipCity, @EmployeeID)";
829828

830829
// Create a command object to execute the insert query within the transaction.
@@ -851,7 +850,7 @@ public IHttpActionResult BatchUpdate(CRUDModel<Orders> value)
851850
// Process the list of deleted records.
852851
if (value.deleted != null && value.deleted.Count > 0)
853852
{
854-
// Define an SQL query to delete records from the "Orders" table based on OrderID.
853+
// Define an SQL query to delete records from the orders table based on OrderID.
855854
string deleteQuery = "DELETE FROM \"Orders\" WHERE \"OrderID\"=@OrderID";
856855

857856
// Create a command object to execute the delete query within the transaction.
@@ -1001,7 +1000,7 @@ namespace MyWebService.Controllers
10011000
[HttpGet]
10021001
private List<Orders> GetOrderData()
10031002
{
1004-
// Define the SQL query to fetch all orders from the "Orders" table, ordered by OrderID.
1003+
// Define the SQL query to fetch all orders from the orders table, ordered by OrderID.
10051004
string query = "SELECT * FROM public.\"Orders\" ORDER BY \"OrderID\"";
10061005

10071006
// Establish a connection to the PostgreSQL database using the connection string.
@@ -1365,7 +1364,7 @@ public object Post(DataManagerRequest DataManagerRequest)
13651364

13661365
### Handling CRUD Operations
13671366

1368-
The Syncfusion ASP.NET MVC Grid seamlessly integrates CRUD (Create, Read, Update and Delete) operations with server-side controller actions through specific properties: `InsertUrl`, `RemoveUrl`, `UpdateUrl`,`CrudUrl`, and `BatchUrl`. These properties enable the Grid to communicate with the data service for every Grid action, facilitating server-side operations.
1367+
The Syncfusion ASP.NET MVC Grid seamlessly integrates CRUD (Create, Read, Update and Delete) operations with server-side controller actions through specific properties: `InsertUrl`, `RemoveUrl`, `UpdateUrl`, and `BatchUrl`. These properties enable the Grid to communicate with the data service for every Grid action, facilitating server-side operations.
13691368

13701369
**CRUD Operations Mapping**
13711370

@@ -1374,8 +1373,7 @@ The following properties enable the Grid to interact with API endpoints for diff
13741373
1. **InsertUrl**: Specifies the URL for inserting new data.
13751374
2. **RemoveUrl**: Specifies the URL for removing existing data.
13761375
3. **UpdateUrl**: Specifies the URL for updating existing data.
1377-
4. **CrudUrl**: Specifies a single URL for all CRUD operations.
1378-
5. **BatchUrl**: Specifies the URL for batch editing.
1376+
4. **BatchUrl**: Specifies the URL for batch editing.
13791377

13801378
To enable editing in ASP.NET MVC Grid, refer to the editing [Documentation](https://ej2.syncfusion.com/aspnetmvc/documentation/grid/editing/edit). In the below example, the inline edit `Mode` is enabled and [Toolbar](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_Toolbar) property is configured to display toolbar items for editing purposes.
13811379
@@ -1438,13 +1436,13 @@ public class CRUDModel<T> where T : class
14381436

14391437
**Insert Operation:**
14401438

1441-
To insert a new row, simply click the **Add** toolbar button. The new record edit form will be displayed as shown below. Upon clicking the **Update** toolbar button, record will inserted into the **Orders** table by calling the following **POST** method of an API.
1439+
To execute the insert operation, you will need to override the `insert` method of the `CustomAdaptor`. Then, integrate the following code snippet into the `CustomAdaptor` class. The below code snippet demonstrated how to handle the insertion of new records within the `insert` method of `CustomAdaptor`. Modify the logic within this method according to the requirements of your application.
14421440

14431441
{% tabs %}
14441442
{% highlight cs tabtitle="GridController.cs" %}
14451443

14461444
/// <summary>
1447-
/// Inserts a new order record into the "Orders" table in the PostgreSQL database.
1445+
/// Inserts a new order record into the orders table in the PostgreSQL database.
14481446
/// </summary>
14491447
/// <param name="value">The CRUDModel containing the order details to be inserted.</param>
14501448
/// <returns>Returns an HTTP response indicating success or failure.</returns>
@@ -1526,13 +1524,13 @@ public IHttpActionResult Insert(CRUDModel<Orders> value)
15261524

15271525
**Update Operation:**
15281526

1529-
To edit a row, first select desired row and click the **Edit** toolbar button. The edit form will be displayed and proceed to modify any column value as per your requirement. Clicking the **Update** toolbar button will update the edit record in the **Orders** table by involving the following **Post** method of an API.
1527+
To execute the update operation, override the `update` method of the `CustomAdaptor`. Then, integrate the following code snippet into the `CustomAdaptor` class. The below code snippet demonstrated how to handle the updating of existing records within the `update` method of the `CustomAdaptor`. Modify the logic within this method according to the requirements of your application.
15301528

15311529
{% tabs %}
15321530
{% highlight cs tabtitle="GridController.cs" %}
15331531

15341532
/// <summary>
1535-
/// Updates an existing order record in the "Orders" table in the PostgreSQL database.
1533+
/// Updates an existing order record in the orders table in the PostgreSQL database.
15361534
/// </summary>
15371535
/// <param name="value">The CRUDModel containing the updated order details.</param>
15381536
/// <returns>Returns an HTTP response indicating success or failure.</returns>
@@ -1615,13 +1613,13 @@ public IHttpActionResult Update(CRUDModel<Orders> value)
16151613

16161614
**Delete Operation**
16171615

1618-
To delete a row, simply select the desired row and click the **Delete** toolbar button. This action will trigger a **DELETE** request to an API, containing the primary key value of the selected record. As a result corresponding record will be removed from the **Orders** table.
1616+
To perform the delete operation, you need to override the `remove` method of the `CustomAdaptor`. Below is the code snippet that you can add to `CustomAdaptor` class. The below code snippet demonstrated how to handle the deletion of existing records within the `remove` method of `CustomAdaptor`. Modify the logic within this method according to the requirements of your application.
16191617

16201618
{% tabs %}
16211619
{% highlight cs tabtitle="GridController.cs" %}
16221620

16231621
/// <summary>
1624-
/// Deletes an order record from the "Orders" table in the PostgreSQL database.
1622+
/// Deletes an order record from the orders table in the PostgreSQL database.
16251623
/// </summary>
16261624
/// <param name="value">The CRUDModel containing the OrderID of the record to be deleted.</param>
16271625
/// <returns>Returns an HTTP response indicating success or failure.</returns>
@@ -1639,7 +1637,7 @@ public IHttpActionResult Remove(CRUDModel<Orders> value)
16391637
// Open the database connection.
16401638
Connection.Open();
16411639

1642-
// Define an SQL query to delete a record from the "Orders" table where OrderID matches.
1640+
// Define an SQL query to delete a record from the orders table where OrderID matches.
16431641
string queryStr = "DELETE FROM \"Orders\" WHERE \"OrderID\"=@OrderID";
16441642

16451643
// Create a command object to execute the delete query.
@@ -1700,13 +1698,13 @@ public IHttpActionResult Remove(CRUDModel<Orders> value)
17001698

17011699
**Batch Operation**
17021700

1703-
To perform batch operation, define the edit `Mode` as **Batch** and specify the `BatchUrl` property in the `DataManager`. Use the **Add** toolbar button to insert new row in batch editing mode. To edit a cell, double-click the desired cell and update the value as required. To delete a record, simply select the record and press the **Delete** toolbar button. Now, all CRUD operations will be executed in single request. Clicking the **Update** toolbar button will update the newly added, edited, or deleted records from the **Orders** table using a single API POST request.
1701+
To perform the batch operation, override the **batchRequest** method of the `CustomAdaptor` and add the following code in the `CustomAdaptor`. The below code snippet demonstrated how to handle the batch update request within the **batchRequest** method of `CustomAdaptor`. Modify the logic within this method according to the requirements of your application.
17041702

17051703
{% tabs %}
17061704
{% highlight cs tabtitle="GridController.cs" %}
17071705

17081706
/// <summary>
1709-
/// Performs batch update operations (insert, update, and delete) on the "Orders" table in a single transaction.
1707+
/// Performs batch update operations (insert, update, and delete) on the orders table in a single transaction.
17101708
/// </summary>
17111709
/// <param name="value">The CRUDModel containing lists of added, changed, and deleted order records.</param>
17121710
/// <returns>Returns an HTTP response indicating the success or failure of the batch operation.</returns>
@@ -1726,7 +1724,7 @@ public IHttpActionResult BatchUpdate(CRUDModel<Orders> value)
17261724
// Process the list of updated records.
17271725
if (value.changed != null && value.changed.Count > 0)
17281726
{
1729-
// Define an SQL query to update records in the "Orders" table.
1727+
// Define an SQL query to update records in the orders table.
17301728
string updateQuery = "UPDATE \"Orders\" SET \"CustomerID\"=@CustomerID, \"Freight\"=@Freight, \"EmployeeID\"=@EmployeeID, \"ShipCity\"=@ShipCity WHERE \"OrderID\"=@OrderID";
17311729

17321730
// Create a command object to execute the update query within the transaction.
@@ -1754,7 +1752,7 @@ public IHttpActionResult BatchUpdate(CRUDModel<Orders> value)
17541752
// Process the list of newly added records.
17551753
if (value.added != null && value.added.Count > 0)
17561754
{
1757-
// Define an SQL query to insert new records into the "Orders" table.
1755+
// Define an SQL query to insert new records into the orders table.
17581756
string insertQuery = "INSERT INTO \"Orders\" (\"CustomerID\", \"Freight\", \"ShipCity\", \"EmployeeID\") VALUES (@CustomerID, @Freight, @ShipCity, @EmployeeID)";
17591757

17601758
// Create a command object to execute the insert query within the transaction.
@@ -1781,7 +1779,7 @@ public IHttpActionResult BatchUpdate(CRUDModel<Orders> value)
17811779
// Process the list of deleted records.
17821780
if (value.deleted != null && value.deleted.Count > 0)
17831781
{
1784-
// Define an SQL query to delete records from the "Orders" table based on OrderID.
1782+
// Define an SQL query to delete records from the orders table based on OrderID.
17851783
string deleteQuery = "DELETE FROM \"Orders\" WHERE \"OrderID\"=@OrderID";
17861784

17871785
// Create a command object to execute the delete query within the transaction.
@@ -1852,9 +1850,7 @@ public IHttpActionResult BatchUpdate(CRUDModel<Orders> value)
18521850
let dataManager = new ejs.data.DataManager({
18531851
url: "https://localhost:xxxx/api/Grid",
18541852
adaptor: new CustomAdaptor(),
1855-
insertUrl: "https://localhost:xxxx/api/Grid/Insert",
1856-
updateUrl: "https://localhost:xxxx/api/Grid/Update",
1857-
removeUrl: "https://localhost:xxxx/api/Grid/Remove",
1853+
batchUrl: "https://localhost:xxxx/api/Grid/BatchUpdate",
18581854
});
18591855
grid.dataSource = dataManager;
18601856
}
@@ -1866,4 +1862,4 @@ public IHttpActionResult BatchUpdate(CRUDModel<Orders> value)
18661862

18671863
When you run the application, the resultant Syncfusion ASP.NET MVC Grid will look like this
18681864

1869-
![Syncfusion ASP.NET MVC Grid bound with PostgreSQL Server data](../images/database/microsoft-sql-batch.gif)
1865+
![Syncfusion ASP.NET MVC Grid bound with PostgreSQL Server data](../images/database/microsoft-sql-batch.gif)

ej2-asp-mvc-toc.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,10 +1261,10 @@
12611261
</li>
12621262
<li>Connecting to Database
12631263
<ul>
1264-
<li><a href="/ej2-asp-mvc/grid/connecting-to-database/mysql-server">MySQL Server</a></li>
1265-
<li><a href="/ej2-asp-mvc/grid/connecting-to-database/dapper">Dapper</a></li>
1266-
<li><a href="/ej2-asp-mvc/grid/connecting-to-database">PostgreSQL Server</a></li>
1267-
<li><a href="/ej2-asp-mvc/grid/connecting-to-database/entity-framework">Entity Framework</a></li>
1264+
<li><a href="/ej2-asp-mvc/grid/connecting-to-database/dapper">Dapper</a></li>
1265+
<li><a href="/ej2-asp-mvc/grid/connecting-to-database/mysql-server">MySQL Server</a></li>
1266+
<li><a href="/ej2-asp-mvc/grid/connecting-to-database/entity-framework">Entity Framework</a></li>
1267+
<li><a href="/ej2-asp-mvc/grid/connecting-to-database">PostgreSQL Server</a></li>
12681268
</ul>
12691269
</li>
12701270
<li><a href="/ej2-asp-mvc/grid/data-annotation">Data Annotation</a></li>

0 commit comments

Comments
 (0)