Contents
This page contains code for the following domain classes:
- City.cs
- District.cs
- Planet.cs
- Settlement.cs
- Town.cs
- TownTypes.cs
City.cs
//////////////////////////////////////////////////////////////////////////////////
// WARNING: This file contains generated code that can be replaced at any time.
// it's generated as a PARTIAL CLASS, so if you need to extend the class
// implement your extensions in an alternate class that won't be overwritten.
//////////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Assets.SQLINQ.SQLite.Net;
using Assets.SQLINQ.SQLite.Patterns;
using Assets.Data.DataDomain;
using Assets.Data.Tables;
namespace Assets.Data.DataDomain {
/// <summary>
/// A place with at least 1000 peons.
/// </summary>
public partial class City : Town {
/// <summary>
/// Used in Single Table Inheritance to differentiate subclasses in the factory
/// </summary>
public new const string cSubType = "CITY";
/// <summary>
/// The words to live by in the city.
/// </summary>
public string Motto {
get { return _Motto; }
set {
if ( _Motto != value ) {
_Motto = value;
IsDirty = true;
}
}
}
protected string _Motto;
/// <summary>
/// Internal Constructor for creating a new object. This is for internal use only.
/// </summary>
protected City() : base( 0 ) {}
/// <summary>
/// Internal Constructor for creating a new object. This is for internal use only.
/// </summary>
public City( int aOID ) : base( aOID ) {}
/// <summary>
/// Internal Constructor for building this instance from a table row.
/// </summary>
/// <param name="aOID">Object Identifier. Set to 0 when creating a new object.</param>
/// <param name="aName">Name of the settlement.</param>
/// <param name="aThePlanetOID">Identifies the settlements on a planet. Important Note: When creating new instance in code set this value to 0, then use the master to add the child. This allows you to work with the objects after you construct them.</param>
/// <param name="aTheDistrictOID">Settlements in the district. Important Note: When creating new instance in code set this value to 0, then use the master to add the child. This allows you to work with the objects after you construct them.</param>
/// <param name="aMayorName">The name of the ruler of the town.</param>
/// <param name="aTheTypeOfTown">Historical or current state of town.</param>
/// <param name="aMotto">The words to live by in the city.</param>
public City(
int aOID
, string aName
, int aThePlanetOID
, int aTheDistrictOID
, string aMayorName
, int aTheTypeOfTown
, string aMotto
) : this( aOID ) {
_Name = aName;
// Construct a master instance for the OID, it doesn't load data until used.
_ThePlanet = new LazyLoadMaster<Planet,PlanetTable>( aThePlanetOID );
// Construct a master instance for the OID, it doesn't load data until used.
_TheDistrict = new LazyLoadMaster<District,DistrictTable>( aTheDistrictOID );
_MayorName = aMayorName;
_TheTypeOfTown = (TownTypes) aTheTypeOfTown;
_Motto = aMotto;
}
/// <summary>
/// Saves the instance to the database. Do not use if saving Units of Work,
/// See the Repository class for more information.
/// </summary>
public override ValidationResult Save() {
ValidationResult MESSAGES = Validate();
if ( MESSAGES.isError ) {
return MESSAGES;
}
// Construct a table and assign all the attributes
SettlementTable TABLE = new SettlementTable {
OID = this.OID , // Identifier
SubType = cSubType , // Subtype Classifier
Name = this.Name , // Regular attribute
ThePlanetOID = this.ThePlanet.OID , // Master Reference to 'Planet'
TheDistrictOID = this.TheDistrict.OID , // Master Reference to 'District'
MayorName = this.MayorName , // Regular attribute
TheTypeOfTown = (int) this.TheTypeOfTown , // Enumeration from 'TownTypes'
Motto = this.Motto , // Regular attribute
};
// Write instance to database
bool RESULT = Repository.Save( TABLE , this );
if ( ! RESULT ) {
MESSAGES.Add(MessageType.Error, "Instance ' #" + OID + " failed to be written to database.", this.GetType().FullName );
}
return MESSAGES;
}
/// <summary>
/// Used to find a specific instance of City for an Object Identifier
/// </summary>
public new static City GetByOID(int aOID) {
return Repository.Factory<SettlementTable,City>( SettlementTable.GetByOID( aOID ) );
}
/// <summary>
/// Used to find all instances and subclass instances of the City
/// </summary>
public new static IEnumerable<City> GetAll() {
List<string> SUBTYPES = new List<string> { City.cSubType };
return Repository.Factory<SettlementTable,City>( SettlementTable.GetAll().Where(A=>SUBTYPES.Contains(A.SubType)) ); // City.cSubType
}
}
}
// WARNING: This file contains generated code that can be replaced at any time.
// it's generated as a PARTIAL CLASS, so if you need to extend the class
// implement your extensions in an alternate class that won't be overwritten.
//////////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Assets.SQLINQ.SQLite.Net;
using Assets.SQLINQ.SQLite.Patterns;
using Assets.Data.DataDomain;
using Assets.Data.Tables;
namespace Assets.Data.DataDomain {
/// <summary>
/// A place with at least 1000 peons.
/// </summary>
public partial class City : Town {
/// <summary>
/// Used in Single Table Inheritance to differentiate subclasses in the factory
/// </summary>
public new const string cSubType = "CITY";
/// <summary>
/// The words to live by in the city.
/// </summary>
public string Motto {
get { return _Motto; }
set {
if ( _Motto != value ) {
_Motto = value;
IsDirty = true;
}
}
}
protected string _Motto;
/// <summary>
/// Internal Constructor for creating a new object. This is for internal use only.
/// </summary>
protected City() : base( 0 ) {}
/// <summary>
/// Internal Constructor for creating a new object. This is for internal use only.
/// </summary>
public City( int aOID ) : base( aOID ) {}
/// <summary>
/// Internal Constructor for building this instance from a table row.
/// </summary>
/// <param name="aOID">Object Identifier. Set to 0 when creating a new object.</param>
/// <param name="aName">Name of the settlement.</param>
/// <param name="aThePlanetOID">Identifies the settlements on a planet. Important Note: When creating new instance in code set this value to 0, then use the master to add the child. This allows you to work with the objects after you construct them.</param>
/// <param name="aTheDistrictOID">Settlements in the district. Important Note: When creating new instance in code set this value to 0, then use the master to add the child. This allows you to work with the objects after you construct them.</param>
/// <param name="aMayorName">The name of the ruler of the town.</param>
/// <param name="aTheTypeOfTown">Historical or current state of town.</param>
/// <param name="aMotto">The words to live by in the city.</param>
public City(
int aOID
, string aName
, int aThePlanetOID
, int aTheDistrictOID
, string aMayorName
, int aTheTypeOfTown
, string aMotto
) : this( aOID ) {
_Name = aName;
// Construct a master instance for the OID, it doesn't load data until used.
_ThePlanet = new LazyLoadMaster<Planet,PlanetTable>( aThePlanetOID );
// Construct a master instance for the OID, it doesn't load data until used.
_TheDistrict = new LazyLoadMaster<District,DistrictTable>( aTheDistrictOID );
_MayorName = aMayorName;
_TheTypeOfTown = (TownTypes) aTheTypeOfTown;
_Motto = aMotto;
}
/// <summary>
/// Saves the instance to the database. Do not use if saving Units of Work,
/// See the Repository class for more information.
/// </summary>
public override ValidationResult Save() {
ValidationResult MESSAGES = Validate();
if ( MESSAGES.isError ) {
return MESSAGES;
}
// Construct a table and assign all the attributes
SettlementTable TABLE = new SettlementTable {
OID = this.OID , // Identifier
SubType = cSubType , // Subtype Classifier
Name = this.Name , // Regular attribute
ThePlanetOID = this.ThePlanet.OID , // Master Reference to 'Planet'
TheDistrictOID = this.TheDistrict.OID , // Master Reference to 'District'
MayorName = this.MayorName , // Regular attribute
TheTypeOfTown = (int) this.TheTypeOfTown , // Enumeration from 'TownTypes'
Motto = this.Motto , // Regular attribute
};
// Write instance to database
bool RESULT = Repository.Save( TABLE , this );
if ( ! RESULT ) {
MESSAGES.Add(MessageType.Error, "Instance ' #" + OID + " failed to be written to database.", this.GetType().FullName );
}
return MESSAGES;
}
/// <summary>
/// Used to find a specific instance of City for an Object Identifier
/// </summary>
public new static City GetByOID(int aOID) {
return Repository.Factory<SettlementTable,City>( SettlementTable.GetByOID( aOID ) );
}
/// <summary>
/// Used to find all instances and subclass instances of the City
/// </summary>
public new static IEnumerable<City> GetAll() {
List<string> SUBTYPES = new List<string> { City.cSubType };
return Repository.Factory<SettlementTable,City>( SettlementTable.GetAll().Where(A=>SUBTYPES.Contains(A.SubType)) ); // City.cSubType
}
}
}
District.cs
//////////////////////////////////////////////////////////////////////////////////
// WARNING: This file contains generated code that can be replaced at any time.
// it's generated as a PARTIAL CLASS, so if you need to extend the class
// implement your extensions in an alternate class that won't be overwritten.
//////////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Assets.SQLINQ.SQLite.Net;
using Assets.SQLINQ.SQLite.Patterns;
using Assets.Data.DataDomain;
using Assets.Data.Tables;
namespace Assets.Data.DataDomain {
/// <summary>
/// State or province on the planet.
/// </summary>
public partial class District : BaseClass {
/// <summary>
/// Used in Single Table Inheritance to differentiate subclasses in the factory
/// </summary>
public new const string cSubType = "DISTRICT";
/// <summary>
/// Settlements in the district.
/// </summary>
public LazyLoadChildren<Settlement , District , SettlementTable> Settlements { get; protected set; }
/// <summary>
/// Name of the district.
/// </summary>
public string Name {
get { return _Name; }
set {
if ( _Name != value ) {
_Name = value;
IsDirty = true;
}
}
}
protected string _Name;
/// <summary>
/// Internal Constructor for creating a new object. This is for internal use only.
/// </summary>
protected District() : base( 0 ) {}
/// <summary>
/// Internal Constructor for creating a new object. This is for internal use only.
/// </summary>
public District( int aOID ) : base( aOID ) {}
/// <summary>
/// Internal Constructor for building this instance from a table row.
/// </summary>
/// <param name="aOID">Object Identifier. Set to 0 when creating a new object.</param>
/// <param name="aName">Name of the district.</param>
public District(
int aOID
, string aName
) : this( aOID ) {
_Name = aName;
// Initialize the Settlements with information about the child relationship
Settlements = new LazyLoadChildren<Settlement, District, SettlementTable>(this,"TheDistrictOID");
}
/// <summary>
/// Saves the instance to the database. Do not use if saving Units of Work,
/// See the Repository class for more information.
/// </summary>
public override ValidationResult Save() {
ValidationResult MESSAGES = Validate();
if ( MESSAGES.isError ) {
return MESSAGES;
}
// Construct a table and assign all the attributes
DistrictTable TABLE = new DistrictTable {
OID = this.OID , // Identifier
SubType = cSubType , // Subtype Classifier
Name = this.Name , // Regular attribute
};
// Write instance to database
bool RESULT = Repository.Save( TABLE , this );
if ( ! RESULT ) {
MESSAGES.Add(MessageType.Error, "Instance ' #" + OID + " failed to be written to database.", this.GetType().FullName );
}
return MESSAGES;
}
/// <summary>
/// Use to find District instances that match a provided "Name".
/// </summary>
public static IEnumerable<District> FindByName(string aName) {
return Repository.Factory<DistrictTable,District>( DistrictTable.FindByName( aName ) );
}
/// <summary>
/// Used to find a specific instance of District for an Object Identifier
/// </summary>
public new static District GetByOID(int aOID) {
return Repository.Factory<DistrictTable,District>( DistrictTable.GetByOID( aOID ) );
}
/// <summary>
/// Used to find all instances and subclass instances of the District
/// </summary>
public new static IEnumerable<District> GetAll() {
return Repository.Factory<DistrictTable,District>( DistrictTable.GetAll() );
}
}
}
// WARNING: This file contains generated code that can be replaced at any time.
// it's generated as a PARTIAL CLASS, so if you need to extend the class
// implement your extensions in an alternate class that won't be overwritten.
//////////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Assets.SQLINQ.SQLite.Net;
using Assets.SQLINQ.SQLite.Patterns;
using Assets.Data.DataDomain;
using Assets.Data.Tables;
namespace Assets.Data.DataDomain {
/// <summary>
/// State or province on the planet.
/// </summary>
public partial class District : BaseClass {
/// <summary>
/// Used in Single Table Inheritance to differentiate subclasses in the factory
/// </summary>
public new const string cSubType = "DISTRICT";
/// <summary>
/// Settlements in the district.
/// </summary>
public LazyLoadChildren<Settlement , District , SettlementTable> Settlements { get; protected set; }
/// <summary>
/// Name of the district.
/// </summary>
public string Name {
get { return _Name; }
set {
if ( _Name != value ) {
_Name = value;
IsDirty = true;
}
}
}
protected string _Name;
/// <summary>
/// Internal Constructor for creating a new object. This is for internal use only.
/// </summary>
protected District() : base( 0 ) {}
/// <summary>
/// Internal Constructor for creating a new object. This is for internal use only.
/// </summary>
public District( int aOID ) : base( aOID ) {}
/// <summary>
/// Internal Constructor for building this instance from a table row.
/// </summary>
/// <param name="aOID">Object Identifier. Set to 0 when creating a new object.</param>
/// <param name="aName">Name of the district.</param>
public District(
int aOID
, string aName
) : this( aOID ) {
_Name = aName;
// Initialize the Settlements with information about the child relationship
Settlements = new LazyLoadChildren<Settlement, District, SettlementTable>(this,"TheDistrictOID");
}
/// <summary>
/// Saves the instance to the database. Do not use if saving Units of Work,
/// See the Repository class for more information.
/// </summary>
public override ValidationResult Save() {
ValidationResult MESSAGES = Validate();
if ( MESSAGES.isError ) {
return MESSAGES;
}
// Construct a table and assign all the attributes
DistrictTable TABLE = new DistrictTable {
OID = this.OID , // Identifier
SubType = cSubType , // Subtype Classifier
Name = this.Name , // Regular attribute
};
// Write instance to database
bool RESULT = Repository.Save( TABLE , this );
if ( ! RESULT ) {
MESSAGES.Add(MessageType.Error, "Instance ' #" + OID + " failed to be written to database.", this.GetType().FullName );
}
return MESSAGES;
}
/// <summary>
/// Use to find District instances that match a provided "Name".
/// </summary>
public static IEnumerable<District> FindByName(string aName) {
return Repository.Factory<DistrictTable,District>( DistrictTable.FindByName( aName ) );
}
/// <summary>
/// Used to find a specific instance of District for an Object Identifier
/// </summary>
public new static District GetByOID(int aOID) {
return Repository.Factory<DistrictTable,District>( DistrictTable.GetByOID( aOID ) );
}
/// <summary>
/// Used to find all instances and subclass instances of the District
/// </summary>
public new static IEnumerable<District> GetAll() {
return Repository.Factory<DistrictTable,District>( DistrictTable.GetAll() );
}
}
}
Planet.cs
//////////////////////////////////////////////////////////////////////////////////
// WARNING: This file contains generated code that can be replaced at any time.
// it's generated as a PARTIAL CLASS, so if you need to extend the class
// implement your extensions in an alternate class that won't be overwritten.
//////////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Assets.SQLINQ.SQLite.Net;
using Assets.SQLINQ.SQLite.Patterns;
using Assets.Data.DataDomain;
using Assets.Data.Tables;
namespace Assets.Data.DataDomain {
/// <summary>
/// Information about a planet.
/// </summary>
public partial class Planet : BaseClass {
/// <summary>
/// Used in Single Table Inheritance to differentiate subclasses in the factory
/// </summary>
public new const string cSubType = "PLANET";
/// <summary>
/// Identifies the settlements on a planet.
/// </summary>
public LazyLoadChildren<Settlement , Planet , SettlementTable> Settlements { get; protected set; }
/// <summary>
/// The name of the planet.
/// </summary>
public string Name {
get { return _Name; }
set {
if ( _Name != value ) {
_Name = value;
IsDirty = true;
}
}
}
protected string _Name;
/// <summary>
/// Internal Constructor for creating a new object. This is for internal use only.
/// </summary>
protected Planet() : base( 0 ) {}
/// <summary>
/// Internal Constructor for creating a new object. This is for internal use only.
/// </summary>
public Planet( int aOID ) : base( aOID ) {}
/// <summary>
/// Internal Constructor for building this instance from a table row.
/// </summary>
/// <param name="aOID">Object Identifier. Set to 0 when creating a new object.</param>
/// <param name="aName">The name of the planet.</param>
public Planet(
int aOID
, string aName
) : this( aOID ) {
_Name = aName;
// Initialize the Settlements with information about the child relationship
Settlements = new LazyLoadChildren<Settlement, Planet, SettlementTable>(this,"ThePlanetOID");
}
/// <summary>
/// Saves the instance to the database. Do not use if saving Units of Work,
/// See the Repository class for more information.
/// </summary>
public override ValidationResult Save() {
ValidationResult MESSAGES = Validate();
if ( MESSAGES.isError ) {
return MESSAGES;
}
// Construct a table and assign all the attributes
PlanetTable TABLE = new PlanetTable {
OID = this.OID , // Identifier
SubType = cSubType , // Subtype Classifier
Name = this.Name , // Regular attribute
};
// Write instance to database
bool RESULT = Repository.Save( TABLE , this );
if ( ! RESULT ) {
MESSAGES.Add(MessageType.Error, "Instance ' #" + OID + " failed to be written to database.", this.GetType().FullName );
}
return MESSAGES;
}
/// <summary>
/// Use to find Planet instances that match a provided "Name".
/// </summary>
public static IEnumerable<Planet> FindByName(string aName) {
return Repository.Factory<PlanetTable,Planet>( PlanetTable.FindByName( aName ) );
}
/// <summary>
/// Used to find a specific instance of Planet for an Object Identifier
/// </summary>
public new static Planet GetByOID(int aOID) {
return Repository.Factory<PlanetTable,Planet>( PlanetTable.GetByOID( aOID ) );
}
/// <summary>
/// Used to find all instances and subclass instances of the Planet
/// </summary>
public new static IEnumerable<Planet> GetAll() {
return Repository.Factory<PlanetTable,Planet>( PlanetTable.GetAll() );
}
}
}
// WARNING: This file contains generated code that can be replaced at any time.
// it's generated as a PARTIAL CLASS, so if you need to extend the class
// implement your extensions in an alternate class that won't be overwritten.
//////////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Assets.SQLINQ.SQLite.Net;
using Assets.SQLINQ.SQLite.Patterns;
using Assets.Data.DataDomain;
using Assets.Data.Tables;
namespace Assets.Data.DataDomain {
/// <summary>
/// Information about a planet.
/// </summary>
public partial class Planet : BaseClass {
/// <summary>
/// Used in Single Table Inheritance to differentiate subclasses in the factory
/// </summary>
public new const string cSubType = "PLANET";
/// <summary>
/// Identifies the settlements on a planet.
/// </summary>
public LazyLoadChildren<Settlement , Planet , SettlementTable> Settlements { get; protected set; }
/// <summary>
/// The name of the planet.
/// </summary>
public string Name {
get { return _Name; }
set {
if ( _Name != value ) {
_Name = value;
IsDirty = true;
}
}
}
protected string _Name;
/// <summary>
/// Internal Constructor for creating a new object. This is for internal use only.
/// </summary>
protected Planet() : base( 0 ) {}
/// <summary>
/// Internal Constructor for creating a new object. This is for internal use only.
/// </summary>
public Planet( int aOID ) : base( aOID ) {}
/// <summary>
/// Internal Constructor for building this instance from a table row.
/// </summary>
/// <param name="aOID">Object Identifier. Set to 0 when creating a new object.</param>
/// <param name="aName">The name of the planet.</param>
public Planet(
int aOID
, string aName
) : this( aOID ) {
_Name = aName;
// Initialize the Settlements with information about the child relationship
Settlements = new LazyLoadChildren<Settlement, Planet, SettlementTable>(this,"ThePlanetOID");
}
/// <summary>
/// Saves the instance to the database. Do not use if saving Units of Work,
/// See the Repository class for more information.
/// </summary>
public override ValidationResult Save() {
ValidationResult MESSAGES = Validate();
if ( MESSAGES.isError ) {
return MESSAGES;
}
// Construct a table and assign all the attributes
PlanetTable TABLE = new PlanetTable {
OID = this.OID , // Identifier
SubType = cSubType , // Subtype Classifier
Name = this.Name , // Regular attribute
};
// Write instance to database
bool RESULT = Repository.Save( TABLE , this );
if ( ! RESULT ) {
MESSAGES.Add(MessageType.Error, "Instance ' #" + OID + " failed to be written to database.", this.GetType().FullName );
}
return MESSAGES;
}
/// <summary>
/// Use to find Planet instances that match a provided "Name".
/// </summary>
public static IEnumerable<Planet> FindByName(string aName) {
return Repository.Factory<PlanetTable,Planet>( PlanetTable.FindByName( aName ) );
}
/// <summary>
/// Used to find a specific instance of Planet for an Object Identifier
/// </summary>
public new static Planet GetByOID(int aOID) {
return Repository.Factory<PlanetTable,Planet>( PlanetTable.GetByOID( aOID ) );
}
/// <summary>
/// Used to find all instances and subclass instances of the Planet
/// </summary>
public new static IEnumerable<Planet> GetAll() {
return Repository.Factory<PlanetTable,Planet>( PlanetTable.GetAll() );
}
}
}
Settlement.cs
//////////////////////////////////////////////////////////////////////////////////
// WARNING: This file contains generated code that can be replaced at any time.
// it's generated as a PARTIAL CLASS, so if you need to extend the class
// implement your extensions in an alternate class that won't be overwritten.
//////////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Assets.SQLINQ.SQLite.Net;
using Assets.SQLINQ.SQLite.Patterns;
using Assets.Data.DataDomain;
using Assets.Data.Tables;
namespace Assets.Data.DataDomain {
/// <summary>
/// Locations on the planet with peons.
/// </summary>
public partial class Settlement : BaseClass {
/// <summary>
/// Used in Single Table Inheritance to differentiate subclasses in the factory
/// </summary>
public new const string cSubType = "SETTLEMENT";
#region --- Lazy Master ThePlanet ---
/// <summary>
/// Internal object to reference the Lazy Master instance
/// </summary>
private LazyLoadMaster<Planet , PlanetTable> _ThePlanet;
/// <summary>
/// Identifies the settlements on a planet.
// </summary>
public Planet ThePlanet {
get { return _ThePlanet.Value; }
set {
if ( _ThePlanet.Value != value ) {
_ThePlanet.Value = value;
IsDirty = true;
}
}
}
#endregion
#region --- Lazy Master TheDistrict ---
/// <summary>
/// Internal object to reference the Lazy Master instance
/// </summary>
private LazyLoadMaster<District , DistrictTable> _TheDistrict;
/// <summary>
/// Settlements in the district.
// </summary>
public District TheDistrict {
get { return _TheDistrict.Value; }
set {
if ( _TheDistrict.Value != value ) {
_TheDistrict.Value = value;
IsDirty = true;
}
}
}
#endregion
/// <summary>
/// Name of the settlement.
/// </summary>
public string Name {
get { return _Name; }
set {
if ( _Name != value ) {
_Name = value;
IsDirty = true;
}
}
}
protected string _Name;
/// <summary>
/// Internal Constructor for creating a new object. This is for internal use only.
/// </summary>
protected Settlement() : base( 0 ) {}
/// <summary>
/// Internal Constructor for creating a new object. This is for internal use only.
/// </summary>
public Settlement( int aOID ) : base( aOID ) {}
/// <summary>
/// Internal Constructor for building this instance from a table row.
/// </summary>
/// <param name="aOID">Object Identifier. Set to 0 when creating a new object.</param>
/// <param name="aName">Name of the settlement.</param>
/// <param name="aThePlanetOID">Identifies the settlements on a planet. Important Note: When creating new instance in code set this value to 0, then use the master to add the child. This allows you to work with the objects after you construct them.</param>
/// <param name="aTheDistrictOID">Settlements in the district. Important Note: When creating new instance in code set this value to 0, then use the master to add the child. This allows you to work with the objects after you construct them.</param>
public Settlement(
int aOID
, string aName
, int aThePlanetOID
, int aTheDistrictOID
) : this( aOID ) {
_Name = aName;
// Construct a master instance for the OID, it doesn't load data until used.
_ThePlanet = new LazyLoadMaster<Planet,PlanetTable>( aThePlanetOID );
// Construct a master instance for the OID, it doesn't load data until used.
_TheDistrict = new LazyLoadMaster<District,DistrictTable>( aTheDistrictOID );
}
/// <summary>
/// Saves the instance to the database. Do not use if saving Units of Work,
/// See the Repository class for more information.
/// </summary>
public override ValidationResult Save() {
ValidationResult MESSAGES = Validate();
if ( MESSAGES.isError ) {
return MESSAGES;
}
// Construct a table and assign all the attributes
SettlementTable TABLE = new SettlementTable {
OID = this.OID , // Identifier
SubType = cSubType , // Subtype Classifier
Name = this.Name , // Regular attribute
ThePlanetOID = this.ThePlanet.OID , // Master Reference to 'Planet'
TheDistrictOID = this.TheDistrict.OID , // Master Reference to 'District'
};
// Write instance to database
bool RESULT = Repository.Save( TABLE , this );
if ( ! RESULT ) {
MESSAGES.Add(MessageType.Error, "Instance ' #" + OID + " failed to be written to database.", this.GetType().FullName );
}
return MESSAGES;
}
/// <summary>
/// Use to find Settlement instances that match a provided "Name".
/// </summary>
public static IEnumerable<Settlement> FindByName(string aName) {
return Repository.Factory<SettlementTable,Settlement>( SettlementTable.FindByName( aName ) );
}
/// <summary>
/// Used to find a specific instance of Settlement for an Object Identifier
/// </summary>
public new static Settlement GetByOID(int aOID) {
return Repository.Factory<SettlementTable,Settlement>( SettlementTable.GetByOID( aOID ) );
}
/// <summary>
/// Used to find all instances and subclass instances of the Settlement
/// </summary>
public new static IEnumerable<Settlement> GetAll() {
return Repository.Factory<SettlementTable,Settlement>( SettlementTable.GetAll() );
}
}
}
// WARNING: This file contains generated code that can be replaced at any time.
// it's generated as a PARTIAL CLASS, so if you need to extend the class
// implement your extensions in an alternate class that won't be overwritten.
//////////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Assets.SQLINQ.SQLite.Net;
using Assets.SQLINQ.SQLite.Patterns;
using Assets.Data.DataDomain;
using Assets.Data.Tables;
namespace Assets.Data.DataDomain {
/// <summary>
/// Locations on the planet with peons.
/// </summary>
public partial class Settlement : BaseClass {
/// <summary>
/// Used in Single Table Inheritance to differentiate subclasses in the factory
/// </summary>
public new const string cSubType = "SETTLEMENT";
#region --- Lazy Master ThePlanet ---
/// <summary>
/// Internal object to reference the Lazy Master instance
/// </summary>
private LazyLoadMaster<Planet , PlanetTable> _ThePlanet;
/// <summary>
/// Identifies the settlements on a planet.
// </summary>
public Planet ThePlanet {
get { return _ThePlanet.Value; }
set {
if ( _ThePlanet.Value != value ) {
_ThePlanet.Value = value;
IsDirty = true;
}
}
}
#endregion
#region --- Lazy Master TheDistrict ---
/// <summary>
/// Internal object to reference the Lazy Master instance
/// </summary>
private LazyLoadMaster<District , DistrictTable> _TheDistrict;
/// <summary>
/// Settlements in the district.
// </summary>
public District TheDistrict {
get { return _TheDistrict.Value; }
set {
if ( _TheDistrict.Value != value ) {
_TheDistrict.Value = value;
IsDirty = true;
}
}
}
#endregion
/// <summary>
/// Name of the settlement.
/// </summary>
public string Name {
get { return _Name; }
set {
if ( _Name != value ) {
_Name = value;
IsDirty = true;
}
}
}
protected string _Name;
/// <summary>
/// Internal Constructor for creating a new object. This is for internal use only.
/// </summary>
protected Settlement() : base( 0 ) {}
/// <summary>
/// Internal Constructor for creating a new object. This is for internal use only.
/// </summary>
public Settlement( int aOID ) : base( aOID ) {}
/// <summary>
/// Internal Constructor for building this instance from a table row.
/// </summary>
/// <param name="aOID">Object Identifier. Set to 0 when creating a new object.</param>
/// <param name="aName">Name of the settlement.</param>
/// <param name="aThePlanetOID">Identifies the settlements on a planet. Important Note: When creating new instance in code set this value to 0, then use the master to add the child. This allows you to work with the objects after you construct them.</param>
/// <param name="aTheDistrictOID">Settlements in the district. Important Note: When creating new instance in code set this value to 0, then use the master to add the child. This allows you to work with the objects after you construct them.</param>
public Settlement(
int aOID
, string aName
, int aThePlanetOID
, int aTheDistrictOID
) : this( aOID ) {
_Name = aName;
// Construct a master instance for the OID, it doesn't load data until used.
_ThePlanet = new LazyLoadMaster<Planet,PlanetTable>( aThePlanetOID );
// Construct a master instance for the OID, it doesn't load data until used.
_TheDistrict = new LazyLoadMaster<District,DistrictTable>( aTheDistrictOID );
}
/// <summary>
/// Saves the instance to the database. Do not use if saving Units of Work,
/// See the Repository class for more information.
/// </summary>
public override ValidationResult Save() {
ValidationResult MESSAGES = Validate();
if ( MESSAGES.isError ) {
return MESSAGES;
}
// Construct a table and assign all the attributes
SettlementTable TABLE = new SettlementTable {
OID = this.OID , // Identifier
SubType = cSubType , // Subtype Classifier
Name = this.Name , // Regular attribute
ThePlanetOID = this.ThePlanet.OID , // Master Reference to 'Planet'
TheDistrictOID = this.TheDistrict.OID , // Master Reference to 'District'
};
// Write instance to database
bool RESULT = Repository.Save( TABLE , this );
if ( ! RESULT ) {
MESSAGES.Add(MessageType.Error, "Instance ' #" + OID + " failed to be written to database.", this.GetType().FullName );
}
return MESSAGES;
}
/// <summary>
/// Use to find Settlement instances that match a provided "Name".
/// </summary>
public static IEnumerable<Settlement> FindByName(string aName) {
return Repository.Factory<SettlementTable,Settlement>( SettlementTable.FindByName( aName ) );
}
/// <summary>
/// Used to find a specific instance of Settlement for an Object Identifier
/// </summary>
public new static Settlement GetByOID(int aOID) {
return Repository.Factory<SettlementTable,Settlement>( SettlementTable.GetByOID( aOID ) );
}
/// <summary>
/// Used to find all instances and subclass instances of the Settlement
/// </summary>
public new static IEnumerable<Settlement> GetAll() {
return Repository.Factory<SettlementTable,Settlement>( SettlementTable.GetAll() );
}
}
}
Town.cs
//////////////////////////////////////////////////////////////////////////////////
// WARNING: This file contains generated code that can be replaced at any time.
// it's generated as a PARTIAL CLASS, so if you need to extend the class
// implement your extensions in an alternate class that won't be overwritten.
//////////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Assets.SQLINQ.SQLite.Net;
using Assets.SQLINQ.SQLite.Patterns;
using Assets.Data.DataDomain;
using Assets.Data.Tables;
namespace Assets.Data.DataDomain {
/// <summary>
/// More than 250 peons in a settlement.
/// </summary>
public partial class Town : Settlement {
/// <summary>
/// Used in Single Table Inheritance to differentiate subclasses in the factory
/// </summary>
public new const string cSubType = "TOWN";
/// <summary>
/// The name of the ruler of the town.
/// </summary>
public string MayorName {
get { return _MayorName; }
set {
if ( _MayorName != value ) {
_MayorName = value;
IsDirty = true;
}
}
}
protected string _MayorName;
/// <summary>
/// Historical or current state of town.
/// </summary>
public TownTypes TheTypeOfTown {
get { return _TheTypeOfTown; }
set {
if ( _TheTypeOfTown != value ) {
_TheTypeOfTown = value;
IsDirty = true;
}
}
}
protected TownTypes _TheTypeOfTown;
/// <summary>
/// Internal Constructor for creating a new object. This is for internal use only.
/// </summary>
protected Town() : base( 0 ) {}
/// <summary>
/// Internal Constructor for creating a new object. This is for internal use only.
/// </summary>
public Town( int aOID ) : base( aOID ) {}
/// <summary>
/// Internal Constructor for building this instance from a table row.
/// </summary>
/// <param name="aOID">Object Identifier. Set to 0 when creating a new object.</param>
/// <param name="aName">Name of the settlement.</param>
/// <param name="aThePlanetOID">Identifies the settlements on a planet. Important Note: When creating new instance in code set this value to 0, then use the master to add the child. This allows you to work with the objects after you construct them.</param>
/// <param name="aTheDistrictOID">Settlements in the district. Important Note: When creating new instance in code set this value to 0, then use the master to add the child. This allows you to work with the objects after you construct them.</param>
/// <param name="aMayorName">The name of the ruler of the town.</param>
/// <param name="aTheTypeOfTown">Historical or current state of town.</param>
public Town(
int aOID
, string aName
, int aThePlanetOID
, int aTheDistrictOID
, string aMayorName
, int aTheTypeOfTown
) : this( aOID ) {
_Name = aName;
// Construct a master instance for the OID, it doesn't load data until used.
_ThePlanet = new LazyLoadMaster<Planet,PlanetTable>( aThePlanetOID );
// Construct a master instance for the OID, it doesn't load data until used.
_TheDistrict = new LazyLoadMaster<District,DistrictTable>( aTheDistrictOID );
_MayorName = aMayorName;
_TheTypeOfTown = (TownTypes) aTheTypeOfTown;
}
/// <summary>
/// Saves the instance to the database. Do not use if saving Units of Work,
/// See the Repository class for more information.
/// </summary>
public override ValidationResult Save() {
ValidationResult MESSAGES = Validate();
if ( MESSAGES.isError ) {
return MESSAGES;
}
// Construct a table and assign all the attributes
SettlementTable TABLE = new SettlementTable {
OID = this.OID , // Identifier
SubType = cSubType , // Subtype Classifier
Name = this.Name , // Regular attribute
ThePlanetOID = this.ThePlanet.OID , // Master Reference to 'Planet'
TheDistrictOID = this.TheDistrict.OID , // Master Reference to 'District'
MayorName = this.MayorName , // Regular attribute
TheTypeOfTown = (int) this.TheTypeOfTown , // Enumeration from 'TownTypes'
};
// Write instance to database
bool RESULT = Repository.Save( TABLE , this );
if ( ! RESULT ) {
MESSAGES.Add(MessageType.Error, "Instance ' #" + OID + " failed to be written to database.", this.GetType().FullName );
}
return MESSAGES;
}
/// <summary>
/// Used to find a specific instance of Town for an Object Identifier
/// </summary>
public new static Town GetByOID(int aOID) {
return Repository.Factory<SettlementTable,Town>( SettlementTable.GetByOID( aOID ) );
}
/// <summary>
/// Used to find all instances and subclass instances of the Town
/// </summary>
public new static IEnumerable<Town> GetAll() {
List<string> SUBTYPES = new List<string> { Town.cSubType,City.cSubType };
return Repository.Factory<SettlementTable,Town>( SettlementTable.GetAll().Where(A=>SUBTYPES.Contains(A.SubType)) ); // Town.cSubType,City.cSubType
}
}
}
// WARNING: This file contains generated code that can be replaced at any time.
// it's generated as a PARTIAL CLASS, so if you need to extend the class
// implement your extensions in an alternate class that won't be overwritten.
//////////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Assets.SQLINQ.SQLite.Net;
using Assets.SQLINQ.SQLite.Patterns;
using Assets.Data.DataDomain;
using Assets.Data.Tables;
namespace Assets.Data.DataDomain {
/// <summary>
/// More than 250 peons in a settlement.
/// </summary>
public partial class Town : Settlement {
/// <summary>
/// Used in Single Table Inheritance to differentiate subclasses in the factory
/// </summary>
public new const string cSubType = "TOWN";
/// <summary>
/// The name of the ruler of the town.
/// </summary>
public string MayorName {
get { return _MayorName; }
set {
if ( _MayorName != value ) {
_MayorName = value;
IsDirty = true;
}
}
}
protected string _MayorName;
/// <summary>
/// Historical or current state of town.
/// </summary>
public TownTypes TheTypeOfTown {
get { return _TheTypeOfTown; }
set {
if ( _TheTypeOfTown != value ) {
_TheTypeOfTown = value;
IsDirty = true;
}
}
}
protected TownTypes _TheTypeOfTown;
/// <summary>
/// Internal Constructor for creating a new object. This is for internal use only.
/// </summary>
protected Town() : base( 0 ) {}
/// <summary>
/// Internal Constructor for creating a new object. This is for internal use only.
/// </summary>
public Town( int aOID ) : base( aOID ) {}
/// <summary>
/// Internal Constructor for building this instance from a table row.
/// </summary>
/// <param name="aOID">Object Identifier. Set to 0 when creating a new object.</param>
/// <param name="aName">Name of the settlement.</param>
/// <param name="aThePlanetOID">Identifies the settlements on a planet. Important Note: When creating new instance in code set this value to 0, then use the master to add the child. This allows you to work with the objects after you construct them.</param>
/// <param name="aTheDistrictOID">Settlements in the district. Important Note: When creating new instance in code set this value to 0, then use the master to add the child. This allows you to work with the objects after you construct them.</param>
/// <param name="aMayorName">The name of the ruler of the town.</param>
/// <param name="aTheTypeOfTown">Historical or current state of town.</param>
public Town(
int aOID
, string aName
, int aThePlanetOID
, int aTheDistrictOID
, string aMayorName
, int aTheTypeOfTown
) : this( aOID ) {
_Name = aName;
// Construct a master instance for the OID, it doesn't load data until used.
_ThePlanet = new LazyLoadMaster<Planet,PlanetTable>( aThePlanetOID );
// Construct a master instance for the OID, it doesn't load data until used.
_TheDistrict = new LazyLoadMaster<District,DistrictTable>( aTheDistrictOID );
_MayorName = aMayorName;
_TheTypeOfTown = (TownTypes) aTheTypeOfTown;
}
/// <summary>
/// Saves the instance to the database. Do not use if saving Units of Work,
/// See the Repository class for more information.
/// </summary>
public override ValidationResult Save() {
ValidationResult MESSAGES = Validate();
if ( MESSAGES.isError ) {
return MESSAGES;
}
// Construct a table and assign all the attributes
SettlementTable TABLE = new SettlementTable {
OID = this.OID , // Identifier
SubType = cSubType , // Subtype Classifier
Name = this.Name , // Regular attribute
ThePlanetOID = this.ThePlanet.OID , // Master Reference to 'Planet'
TheDistrictOID = this.TheDistrict.OID , // Master Reference to 'District'
MayorName = this.MayorName , // Regular attribute
TheTypeOfTown = (int) this.TheTypeOfTown , // Enumeration from 'TownTypes'
};
// Write instance to database
bool RESULT = Repository.Save( TABLE , this );
if ( ! RESULT ) {
MESSAGES.Add(MessageType.Error, "Instance ' #" + OID + " failed to be written to database.", this.GetType().FullName );
}
return MESSAGES;
}
/// <summary>
/// Used to find a specific instance of Town for an Object Identifier
/// </summary>
public new static Town GetByOID(int aOID) {
return Repository.Factory<SettlementTable,Town>( SettlementTable.GetByOID( aOID ) );
}
/// <summary>
/// Used to find all instances and subclass instances of the Town
/// </summary>
public new static IEnumerable<Town> GetAll() {
List<string> SUBTYPES = new List<string> { Town.cSubType,City.cSubType };
return Repository.Factory<SettlementTable,Town>( SettlementTable.GetAll().Where(A=>SUBTYPES.Contains(A.SubType)) ); // Town.cSubType,City.cSubType
}
}
}
Town types.cs
//////////////////////////////////////////////////////////////////////////////////
// WARNING: This file contains generated code that can be replaced at any time
//////////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Assets.SQLINQ.SQLite.Net;
using Assets.SQLINQ.SQLite.Patterns;
using Assets.Data.Tables;
using Assets.Data.Utility;
namespace Assets.Data.DataDomain {
/// <summary>
/// Different types of towns.
/// </summary>
public enum TownTypes : int {
/// <summary>
/// Currently populated with peons.
/// </summary>
Populated = 11,
/// <summary>
/// A town that is currently protected in the district, nobody lives there.
/// </summary>
Historical = 21,
/// <summary>
/// Was a town, but they ran away.
/// </summary>
Abandoned = 25,
/// <summary>
/// Location of a town destroyed by a natural disaster.
/// </summary>
Destroyed = 31,
}
}
// WARNING: This file contains generated code that can be replaced at any time
//////////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Assets.SQLINQ.SQLite.Net;
using Assets.SQLINQ.SQLite.Patterns;
using Assets.Data.Tables;
using Assets.Data.Utility;
namespace Assets.Data.DataDomain {
/// <summary>
/// Different types of towns.
/// </summary>
public enum TownTypes : int {
/// <summary>
/// Currently populated with peons.
/// </summary>
Populated = 11,
/// <summary>
/// A town that is currently protected in the district, nobody lives there.
/// </summary>
Historical = 21,
/// <summary>
/// Was a town, but they ran away.
/// </summary>
Abandoned = 25,
/// <summary>
/// Location of a town destroyed by a natural disaster.
/// </summary>
Destroyed = 31,
}
}