MySqlDataContextOptions<TAdoDbContext>.IgnoreSpace Property
.NET Standard 2.x
Indicates whether extra spaces in SQL statements are ignored.
Namespace: SnapObjects.Data
Assembly: SnapObjects.Data.dll
Syntax
public bool? IgnoreSpace { get; set; }
Property Value
System.Nullabe<System.Boolean>
Returns a boolean value indicating whether to ignore spaces in SQL statements.
The default value is null
if not specified.
Examples
Example 1
The following code example demonstrates how to use the IgnoreSpace
option and set this option to true.
using SnapObjects.Data;
using SnapObjects.Data.MySql;
namespace Appeon.ApiDoc.MySqlDataContextOptions_GenericExamples
{
public class IgnoreSpaceExample
{
private MySqlDataContextOptions<MySqlDataContext> _contextOptions;
public IgnoreSpaceExample(string connectionString)
{
_contextOptions = new MySqlDataContextOptions<MySqlDataContext>(connectionString);
}
public void Example1()
{
_contextOptions.IgnoreSpace = true;
var context = new MySqlDataContext(_contextOptions);
context.SqlExecutor.Select<DynamicModel>("select count (*) from authors");
/*
The following SQL is generated:
SQL:
select count (*) from authors
*/
}
}
}
Example 2
The following code example demonstrates that it will throw exception since the IgnoreSpace
option is false.
public void Example2()
{
_contextOptions.IgnoreSpace = false;
var context = new MySqlDataContext(_contextOptions);
context.SqlExecutor.Select<DynamicModel>("select count (*) from authors");
/*
The following SQL is generated and throw an exception:
SQL:
select count (*) from authors
Exception thrown: 'SnapObjects.Data.DbExecuteException' in SnapObjects.Data.dll
An unhandled exception of type 'SnapObjects.Data.DbExecuteException' occurred in SnapObjects.Data.dll
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '*) from authors'
*/
}
Applies to
.NET Standard
2.x