public void DefineView(ViewInfo viewInfo) { if (viewInfo == null) { throw new ArgumentNullException("viewInfo"); } var dataTableInfo = viewInfo.TableInfo; var viewTable = Transaction.GetMutableTable(SystemSchema.ViewTableName); var viewName = dataTableInfo.TableName; var query = viewInfo.QueryExpression; var viewInfoData = viewInfo.AsBinary(); // Create the view record var rdat = viewTable.NewRow(); rdat.SetValue(0, dataTableInfo.SchemaName.Name); rdat.SetValue(1, dataTableInfo.Name); rdat.SetValue(2, query.ToString()); rdat.SetValue(3, DataObject.Binary(viewInfoData)); // Find the entry from the view that equals this name var t = FindViewEntry(viewName); // Delete the entry if it already exists. if (t.RowCount == 1) { viewTable.Delete(t); } // Insert the new view entry in the system view table viewTable.AddRow(rdat); // Notify that this database object has been successfully created. Transaction.Registry.RegisterEvent(new ObjectCreatedEvent(viewName, DbObjectType.View)); // Change to the view table viewTableChanged = true; }
public void DefineView(ViewInfo viewInfo) { if (viewInfo == null) throw new ArgumentNullException("viewInfo"); var dataTableInfo = viewInfo.TableInfo; var viewTable = Transaction.GetMutableTable(SystemSchema.ViewTableName); var viewName = dataTableInfo.TableName; var query = viewInfo.QueryExpression; var viewInfoData = viewInfo.AsBinary(); // Create the view record var rdat = viewTable.NewRow(); rdat.SetValue(0, dataTableInfo.SchemaName.Name); rdat.SetValue(1, dataTableInfo.Name); rdat.SetValue(2, query.ToString()); rdat.SetValue(3, DataObject.Binary(viewInfoData)); // Find the entry from the view that equals this name var t = FindViewEntry(viewName); // Delete the entry if it already exists. if (t.RowCount == 1) { viewTable.Delete(t); } // Insert the new view entry in the system view table viewTable.AddRow(rdat); // Notify that this database object has been successfully created. Transaction.Registry.RegisterEvent(new ObjectCreatedEvent(viewName, DbObjectType.View)); // Change to the view table viewTableChanged = true; }