Method CreateView
- Namespace
- YndigoBlue.Velocity.Engine
- Assembly
- YndigoBlue.Velocity.dll
CreateView(View)
public void CreateView(View view)
Parameters
viewView
CreateView(View, bool)
Creates a database view based on a query, optionally overwriting if it exists.
public void CreateView(View view, bool overwrite)
Parameters
viewViewThe View object defining the view to create.
overwriteboolIf true, drops and recreates the view if it exists; if false, throws an error if it exists.
Examples
using (var m = new Manager(conn))
{
var schema = m.LoadSchema("app");
var ordersTable = schema["orders"];
var query = new Query()
.Select([
ordersTable["customer_id"],
new Aggregate("total_sales", ordersTable["total"], AggregateType.Sum)
])
.From(ordersTable)
.GroupBy([ordersTable["customer_id"]]);
var view = new View(schema, "customer_sales", query);
m.CreateView(view, overwrite: true);
}
Exceptions
- DbException
Thrown when a database error occurs.