ISqlBuilderCache.GetModifiable<TSqlBuilder>(string sqlBuilderName) Method
.NET Standard 2.x
Gets a modifiable TSqlBuilder
object by the specified cache name.
Namespace: SnapObjects.Data
Assembly: SnapObjects.Data.dll
Syntax
TSqlBuilder GetModifiable<TSqlBuilder>(string sqlBuilderName) where TSqlBuilder : ISqlBuilder;
Type Parameters
TSqlBuilder
The type of a derived interface of ISqlBuilder, such as ISqlQueryBuilder.
Parameters
sqlBuilderName
System.String
The cache name for the ISqlBuilder
object when it is cached.
Returns
TSqlBuilder
If the TSqlBuilder
object is specified as read-only when cached, returns a TSqlBuilder
object by the specified cache name; otherwise, throws an exception.
Examples
The following code example demonstrates how to get a modifiable ISqlBuilder
object via the cache name.
using SnapObjects.Data;
using System;
namespace Appeon.ApiDoc.ISqlBuilderCacheExamples
{
public class GetModifiableExample
{
private readonly SchoolContext _context;
public GetModifiableExample(SchoolContext context)
{
_context = context;
}
public void Example()
{
// Creates a SqlQueryBuilder object.
var build = SqlBuilderFactory.Create<ISqlQueryBuilder>("original sql");
build.Select("select Title from Course wherer CourseID = 1050");
// Generates a SqlBuilderCache object via SqlBuilderFactory.Cache.
var cache = SqlBuilderFactory.Cache;
// Injects the SqlQueryBuilder to the SqlBuilderCache object.
// Sets the read-only property to false.
cache.Set("querySql", build, false);
// Gets the ISqlBuild object whose name is "querySql".
var get = cache.GetModifiable<ISqlQueryBuilder>("querySql");
Console.WriteLine("SqlBuild Name = {0}", get.Name);
/*This code produces the following output:
SqlBuild Name = original sql
*/
}
}
}
Applies to
.NET Standard
2.x