ISqlModelMapper.TrackSqlCUD(string sqlText, params object[] parameters) Method
.NET Standard 2.x
Tracks a database table operation (insert, update or delete) using a raw SQL statement (INSERT, UPDATE, or DELETE). When ISqlModelMapper.SaveChanges method is called, the SQL statement will be executed.
Namespace: SnapObjects.Data
Assembly: SnapObjects.Data.dll
Syntax
public ISqlModelMapper TrackSqlCUD(string sqlText, params object[] parameters);
Parameters
sqlText
System.String
An SQL INSERT, UPDATE, or DELETE statement.
Use : or @ symbol at the beginning to represent the parameter required by the SQL statement.
parameters
System.Object[]
The arguments required by the SQL statement. The order of arguments here must be the same as the order of arguments in sqlText.
Returns
SnapObjects.Data.ISqlModelMapper
Returns an ISqlModelMapper
object, which can be used for executing other methods.
Examples
The following code example demonstrates how to use the TrackSqlCUD method.
using System;
namespace Appeon.ApiDoc.ISqlModelMapperExamples
{
public class TrackSqlCUDExample
{
private SchoolContext _context;
public TrackSqlCUDExample(SchoolContext dataContext)
{
// Sets the data context.
_context = dataContext;
}
public void Example()
{
var mapper = _context.SqlModelMapper;
// Update a record.
var master = mapper.TrackSqlCUD("UPDATE OnlineCourse" +
" SET URL =" +
"'http://www.fineartschool.net/Poetry/test'" +
" WHERE courseID = @id", 2030);
var dbResult = master.SaveChanges();
// Shows the saving result.
Console.WriteLine("{0} records have been updated into the database.",
dbResult.AffectedCount);
}
}
}
Example Refer To
Model Class: OnlineCourse
Applies to
.NET Standard
2.x