mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-19 21:13:28 -07:00
added marr.datamapper source code for easy debugging.
This commit is contained in:
parent
58a05fcef8
commit
3cdff3bb71
96 changed files with 9198 additions and 363 deletions
91
Marr.Data/QGen/View.cs
Normal file
91
Marr.Data/QGen/View.cs
Normal file
|
@ -0,0 +1,91 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Marr.Data.Mapping;
|
||||
|
||||
namespace Marr.Data.QGen
|
||||
{
|
||||
/// <summary>
|
||||
/// This class represents a View. A view can hold multiple tables (and their columns).
|
||||
/// </summary>
|
||||
public class View : Table, IEnumerable<Table>
|
||||
{
|
||||
private string _viewName;
|
||||
private Table[] _tables;
|
||||
private Mapping.ColumnMapCollection _columns;
|
||||
|
||||
public View(string viewName, Table[] tables)
|
||||
: base(tables[0].EntityType, JoinType.None)
|
||||
{
|
||||
_viewName = viewName;
|
||||
_tables = tables;
|
||||
}
|
||||
|
||||
public Table[] Tables
|
||||
{
|
||||
get { return _tables; }
|
||||
}
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return _viewName;
|
||||
}
|
||||
set
|
||||
{
|
||||
_viewName = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override string Alias
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.Alias;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.Alias = value;
|
||||
|
||||
// Sync view tables
|
||||
foreach (Table table in _tables)
|
||||
{
|
||||
table.Alias = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all the columns from all the tables included in the view.
|
||||
/// </summary>
|
||||
public override Mapping.ColumnMapCollection Columns
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_columns == null)
|
||||
{
|
||||
var allColumns = _tables.SelectMany(t => t.Columns);
|
||||
_columns = new ColumnMapCollection();
|
||||
_columns.AddRange(allColumns);
|
||||
}
|
||||
|
||||
return _columns;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerator<Table> GetEnumerator()
|
||||
{
|
||||
foreach (Table table in _tables)
|
||||
{
|
||||
yield return table;
|
||||
}
|
||||
}
|
||||
|
||||
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
|
||||
{
|
||||
return this.GetEnumerator();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue