SQL view generation framework for creating database views from entity attributes.
C:\Source\Birko.Data.SQL.View\
- Generate database views from C# attributes
- Automate view creation
- Support for complex view definitions
- Cross-database compatibility
ViewAttribute- Marks entity for view generationViewColumnAttribute- Defines view columnViewJoinAttribute- Defines view joinsViewFilterAttribute- Defines view filters
ViewGenerator<T>- View generatorViewBuilder- View query builderViewDefinition- View metadata
AbstractConnector_CreateSelectCommand.cs— Builds SELECT command from view metadataAbstractConnector_SelectView.cs— SelectView methods for querying view dataAbstractConnector_SelectViewCount.cs— Count queries against views
AbstractConnectorBase_View.cs—BuildViewSelectSql,BuildCreateViewSql(virtual),BuildViewJoinConditionSqlAbstractConnector_CreateView.cs— Sync:CreateView,DropView,RecreateView,ViewExists,CreateViewIfNotExists,CreateViews,DropViewsAbstractAsyncConnector_CreateView.cs— Async equivalents:CreateViewAsync,DropViewAsync,RecreateViewAsync,ViewExistsAsync,CreateViewIfNotExistsAsync,CreateViewsAsync,DropViewsAsync
- Birko.Data.SQL.MSSql.View —
CREATE OR ALTER VIEW,sys.viewscatalog - Birko.Data.SQL.PostgreSQL.View —
information_schema.views, materialized view support - Birko.Data.SQL.MySQL.View —
information_schema.VIEWSwithTABLE_SCHEMAscoping - Birko.Data.SQL.SqLite.View —
CREATE VIEW IF NOT EXISTS,sqlite_mastercatalog
DataBase_View.cs— View metadata loading and caching
FunctionField.cs— Base aggregate function fieldBooleanFunction.cs,CharFunction.cs,DateTimeFunction.cs,DecimalFunction.cs,GuidFunction.cs,IntegerFunction.cs,StringFunction.cs— Type-specific function fields
View.cs— View metadata model (tables, joins, fields, aggregate detection)
using Birko.Data.SQL.View.Attributes;
[View("customer_orders_view")]
public class CustomerOrderView
{
[ViewColumn("customer_id", "Id")]
public Guid CustomerId { get; set; }
[ViewColumn("customer_name", "Name")]
public string CustomerName { get; set; }
[ViewColumn("order_count")]
public int OrderCount { get; set; }
[ViewColumn("total_spent")]
public decimal TotalSpent { get; set; }
}using Birko.Data.SQL.View;
var generator = new ViewGenerator<CustomerOrderView>();
var sql = generator.GenerateCreateView(connection);
// Executes:
// CREATE VIEW customer_orders_view AS
// SELECT
// c.Id AS customer_id,
// c.Name AS customer_name,
// COUNT(o.Id) AS order_count,
// SUM(o.Total) AS total_spent
// FROM Customers c
// LEFT JOIN Orders o ON o.CustomerId = c.Id
// GROUP BY c.Id, c.Name[View("product_category_view")]
[ViewJoin("Categories", "CategoryId", "Id")]
public class ProductCategoryView
{
[ViewColumn("Id")]
public Guid ProductId { get; set; }
[ViewColumn("Name")]
public string ProductName { get; set; }
[ViewColumn("CategoryName", "Categories.Name")]
public string CategoryName { get; set; }
}[View("active_users_view")]
[ViewFilter("IsActive = true")]
[ViewFilter("DeletedAt IS NULL")]
public class ActiveUsersView
{
[ViewColumn("Id")]
public Guid Id { get; set; }
[ViewColumn("Email")]
public string Email { get; set; }
}For PostgreSQL:
[View("user_stats", Materialized = true, RefreshInterval = "1 hour")]
public class UserStatsView
{
[ViewColumn("UserId")]
public Guid UserId { get; set; }
[ViewColumn("LoginCount")]
public int LoginCount { get; set; }
}- Birko.Data.Core
- Birko.Data.Stores
- Birko.Data.SQL
- PostgreSQL (including materialized views)
- SQL Server (indexed views)
- MySQL
- SQLite
- View naming - Use descriptive names with
_viewsuffix - Column aliases - Always provide readable column names
- Indexes - Create indexes on views for performance
- Refresh strategy - For materialized views, set appropriate refresh intervals
- Dependencies - Be aware of underlying table changes
- Reporting
- Data aggregation
- Security (column-level)
- Simplified queries
- Performance optimization
- Data isolation
When making changes that affect the public API, features, or usage patterns of this project, update the README.md accordingly. This includes:
- New classes, interfaces, or methods
- Changed dependencies
- New or modified usage examples
- Breaking changes
When making major changes to this project, update this CLAUDE.md to reflect:
- New or renamed files and components
- Changed architecture or patterns
- New dependencies or removed dependencies
- Updated interfaces or abstract class signatures
- New conventions or important notes
Every new public functionality must have corresponding unit tests. When adding new features:
- Create test classes in the corresponding test project
- Follow existing test patterns (xUnit + FluentAssertions)
- Test both success and failure cases
- Include edge cases and boundary conditions