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.MySqlDataContextOptionsExamples
{
public class IgnoreSpaceExample
{
private readonly MySqlContext _context;
public IgnoreSpaceExample(MySqlContext context)
{
_context = context;
}
public void Example1()
{
((MySqlDataContextOptions)_context.ContextOptions).IgnoreSpace = true;
_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()
{
((MySqlDataContextOptions)_context.ContextOptions).IgnoreSpace = false;
// throw an exception
_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