public class PrimaryKeyAttribute : Attribute
Public Class PrimaryKeyAttribute
Inherits Attribute
type PrimaryKeyAttribute =
class
inherit Attribute
end
using System.Text;
using Firefly.Box.Data;
using Firefly.Box;
using Firefly.Box.Data.Advanced;
using Firefly.Box.Data.DataProvider;
namespace TestFirefly.Box.Documentation
{
/// <summary>
/// This data base is based on tables from the Microsoft demo database "pubs". It's scripts can be downloaded from:
/// http://www.microsoft.com/downloads/details.aspx?familyid=06616212-0356-46a0-8da2-eebc53a68034&displaylang=en
/// </summary>
public class Pubs
{
public class Employees : Entity
{
[PrimaryKey]
internal readonly TextColumn Id = new TextColumn("emp_id", "9", "Id");
internal readonly TextColumn FirstName = new TextColumn("fname", "20", "First name");
internal readonly TextColumn MiddleInitial = new TextColumn("minit", "1", "Middle initial");
internal readonly TextColumn LastName = new TextColumn("lname", "30", "Last name");
internal readonly JobId JobId = new JobId();
internal readonly JobLevel JobLevel = new JobLevel();
internal readonly PublisherId PublisherId = new PublisherId();
public Employees():base("employee",DataSource)
{
}
public void InitializeWithTestData()
{
Truncate();
Insert("A-C71970F", "Aria", "", "Cruz", 10, 87, "1389");
Insert("A-R89858F", "Annette", "", "Roulet", 6, 152, "9999");
Insert("AMD15433F", "Ann", "M", "Devon", 3, 200, "9952");
Insert("ARD36773F", "Anabela", "R", "Domingues", 8, 100, "0877");
Insert("CFH28514M", "Carlos", "F", "Hernadez", 5, 211, "9999");
Insert("CGS88322F", "Carine", "G", "Schmitt", 13, 64, "1389");
Insert("DBT39435M", "Daniel", "B", "Tonini", 11, 75, "0877");
Insert("DWR65030M", "Diego", "W", "Roel", 6, 192, "1389");
Insert("ENL44273F", "Elizabeth", "N", "Lincoln", 14, 35, "0877");
Insert("F-C16315M", "Francisco", "", "Chang", 4, 227, "9952");
Insert("GHT50241M", "Gary", "H", "Thomas", 9, 170, "0736");
Insert("H-B39728F", "Helen", "", "Bennett", 12, 35, "0877");
Insert("HAN90777M", "Helvetius", "A", "Nagy", 7, 120, "9999");
Insert("HAS54740M", "Howard", "A", "Snyder", 12, 100, "0736");
Insert("JYL26161F", "Janine", "Y", "Labrune", 5, 172, "9901");
Insert("KFJ64308F", "Karin", "F", "Josephs", 14, 100, "0736");
Insert("KJJ92907F", "Karla", "J", "Jablonski", 9, 170, "9999");
Insert("L-B31947F", "Lesley", "", "Brown", 7, 120, "0877");
Insert("LAL21447M", "Laurence", "A", "Lebihan", 5, 175, "0736");
Insert("M-L67958F", "Maria", "", "Larsson", 7, 135, "1389");
Insert("M-P91209M", "Manuel", "", "Pereira", 8, 101, "9999");
Insert("M-R38834F", "Martine", "", "Rance", 9, 75, "0877");
Insert("MAP77183M", "Miguel", "A", "Paolino", 11, 112, "1389");
Insert("MAS70474F", "Margaret", "A", "Smith", 9, 78, "1389");
Insert("MFS52347M", "Martin", "F", "Sommer", 10, 165, "0736");
Insert("MGK44605M", "Matti", "G", "Karttunen", 6, 220, "0736");
Insert("MJP25939M", "Maria", "J", "Pontes", 5, 246, "1756");
Insert("MMS49649F", "Mary", "M", "Saveley", 8, 175, "0736");
Insert("PCM98509F", "Patricia", "C", "McKenna", 11, 150, "9999");
Insert("PDI47470M", "Palle", "D", "Ibsen", 7, 195, "0736");
Insert("PHF38899M", "Peter", "H", "Franken", 10, 75, "0877");
Insert("PMA42628M", "Paolo", "M", "Accorti", 13, 35, "0877");
Insert("POK93028M", "Pirkko", "O", "Koskitalo", 10, 80, "9999");
Insert("PSA89086M", "Pedro", "S", "Afonso", 14, 89, "1389");
Insert("PSP68661F", "Paula", "S", "Parente", 8, 125, "1389");
Insert("PTC11962M", "Philip", "T", "Cramer", 2, 215, "9952");
Insert("PXH22250M", "Paul", "X", "Henriot", 5, 159, "0877");
Insert("R-M53550M", "Roland", "", "Mendel", 11, 150, "0736");
Insert("RBM23061F", "Rita", "B", "Muller", 5, 198, "1622");
Insert("SKO22412M", "Sven", "K", "Ottlieb", 5, 150, "1389");
Insert("TPO55093M", "Timothy", "P", "O'Rourke", 13, 100, "0736");
Insert("VPA30890F", "Victoria", "P", "Ashworth", 6, 140, "0877");
Insert("Y-L77953M", "Yoshi", "", "Latimer", 12, 32, "1389");
}
public void Insert(Text id,Text firstName,Text middleInitial,Text lastName,int jobid,int jobLevel,string publisherId)
{
Employees e = new Employees();
BusinessProcess bp = new BusinessProcess();
bp.From = e;
bp.AddAllColumns();
bp.Activity = Activities.Insert;
bp.ForFirstRow(delegate()
{
e.Id.Value = id;
e.FirstName.Value = firstName;
e.MiddleInitial.Value = middleInitial;
e.LastName.Value = lastName;
e.JobId.Value = jobid;
e.JobLevel.Value = jobLevel;
e.PublisherId.Value = publisherId;
});
}
}
public class Jobs : Entity
{
[PrimaryKey]
internal readonly JobId Id = new JobId();
internal readonly TextColumn Description = new TextColumn("Job_desc", "50", "Description");
internal readonly JobLevel MinLevel = new JobLevel("min_lvl"){Caption = "Min Level"};
internal readonly JobLevel MaxLevel = new JobLevel("max_lvl"){Caption = "Max Level"};
public Jobs():base("jobs",DataSource)
{
}
public void InitializeWithTestData()
{
Truncate();
Insert(1, "New Hire - Job not specified", 10, 10);
Insert(2, "Chief Executive Officer", 200, 250);
Insert(3, "Business Operations Manager", 175, 225);
Insert(4, "Chief Financial Officier", 175, 250);
Insert(5, "Publisher", 150, 250);
Insert(6, "Managing Editor", 140, 225);
Insert(7, "Marketing Manager", 120, 200);
Insert(8, "Public Relations Manager", 100, 175);
Insert(9, "Acquisitions Manager", 75, 175);
Insert(10, "Productions Manager", 75, 165);
Insert(11, "Operations Manager", 75, 150);
Insert(12, "Editor", 25, 100);
Insert(13, "Sales Representative", 25, 100);
Insert(14, "Designer", 25, 100);
}
public void Insert(int jobId,Text description,int minLevel,int maxLevel)
{
Jobs j = new Jobs();
BusinessProcess bp = new BusinessProcess();
bp.From = j;
bp.AddAllColumns();
bp.Activity = Activities.Insert;
bp.ForFirstRow(delegate()
{
j.Id.Value = jobId;
j.Description.Value = description;
j.MinLevel.Value = minLevel;
j.MaxLevel.Value = maxLevel;
});
}
}
public class Publishers : Entity
{
[PrimaryKey]
internal readonly PublisherId Id = new PublisherId();
internal readonly TextColumn Name = new TextColumn("pub_name", "40", "Name");
internal readonly TextColumn City = new TextColumn("City", "20");
internal readonly TextColumn State = new TextColumn("State", "2");
internal readonly TextColumn Country = new TextColumn("Country");
public Publishers():base("Publishers",DataSource)
{
}
public void InitializeWithTestData()
{
Truncate();
Insert("0736", "New Moon Books", "Boston", "MA", "USA");
Insert("0877", "Binnet & Hardley", "Washington", "DC", "USA");
Insert("1389", "Algodata Infosystems", "Berkeley", "CA", "USA");
Insert("1622", "Five Lakes Publishing", "Chicago", "IL", "USA");
Insert("1756", "Ramona Publishers", "Dallas", "TX", "USA");
Insert("9901", "GGG&G", "Mnchen", "", "Germany");
Insert("9952", "Scootney Books", "New York", "NY", "USA");
Insert("9999", "Lucerne Publishing", "Paris", "", "France");
}
public void Insert(Text publisherId,Text name,Text city,Text state,Text country)
{
Publishers p = new Publishers();
BusinessProcess bp = new BusinessProcess();
bp.From = p;
bp.AddAllColumns();
bp.Activity = Activities.Insert;
bp.ForFirstRow(delegate()
{
p.Id.Value = publisherId;
p.Name.Value = name;
p.City.Value = city;
p.State.Value = state;
p.Country.Value = country;
});
}
}
static Pubs()
{
// a dataset datasource
DataSource = new DataSetDataProvider();
// An mssql datasource that access the pubs db
/*DataSource =
SQLDataProviderBase.CreateSqlClientDataProvider(
"Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=pubs;Data Source=(local)\\SQLEXPRESS;Connect Timeout=5;");*/
}
public static readonly DataSetDataProvider DataSource;
public class JobId : NumberColumn
{
public JobId()
: base("job_id", "2", "Job Id")
{
}
}
public class JobLevel : NumberColumn
{
public JobLevel(string name)
: base(name ?? "job_lvl", "3", "Job level")
{
}
public JobLevel()
: this(null)
{
}
}
public class PublisherId : TextColumn
{
public PublisherId()
: base("pub_id", "4", "publisher id")
{
}
}
}
}
EntityPrimaryKeyAttribute | Initializes a new instance of the EntityPrimaryKeyAttribute class. |
Identity | Used to mark Identity columns in the database. |
TypeId | When implemented in a derived class, gets a unique identifier for this Attribute. (Inherited from Attribute) |
Equals | Returns a value that indicates whether this instance is equal to a specified object. (Inherited from Attribute) |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object) |
GetHashCode | Returns the hash code for this instance. (Inherited from Attribute) |
GetType | Gets the Type of the current instance. (Inherited from Object) |
IsDefaultAttribute | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from Attribute) |
Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute) |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object) |
ToString | Returns a string that represents the current object. (Inherited from Object) |