Signum Framework Logo
"Open framework that encourages convention over configuration, using C# code,
not XML files, to model at the right level of abstraction and achieve deadlines.
...but also has a full Linq provider, and syncs the schema for you!"
Login
RSS

Search

»



Main
Index
Map
Videos
Download
Source code
Tutorials
Forum
FAQ



Image



PoweredBy

Database - Query: Data Model Apendix

RSS
Modified on 2009/02/14 15:14 by helen Categorized as SignumEngine, SignumEntities, SignumWindows
This page just has the example data model that is used in Database - Query

Example's Data Model Code

Here are the entity classes used as the Data Model. Just usual Signum Entities.

    [Serializable]
    public class BugDN : Entity
    {
        string description;
        public string Description
        {
            get { return description; }
            set { Set(ref description, value, "Description"); }
        }

DateTime start; public DateTime Start { get { return start; } set { if (Set(ref start, value, "Start")) CalculateHours(); } }

DateTime? end; public DateTime? End { get { return end; } set { if (Set(ref end, value, "End")) CalculateHours(); } }

decimal? hours; public decimal? Hours { get { return hours; } }

Status status; public Status Status { get { return status; } set { Set(ref status, value, "Status"); } }

IBugDiscoverer discoverer; [NotNullValidator] public IBugDiscoverer Discoverer { get { return discoverer; } set { Set(ref discoverer, value, "Discoverer"); } }

DeveloperDN fixer; public DeveloperDN Fixer { get { return fixer; } set { Set(ref fixer, value, "Fixer"); } }

Lazy<ProjectDN> project; [NotNullValidator] public Lazy<ProjectDN> Project { get { return project; } set { Set(ref project, value, "Project"); } }

MList<CommentDN> comments; public MList<CommentDN> Comments { get { return comments; } set { Set(ref comments, value, "Comments"); } }

protected override void PreSaving() { base.PreSaving(); CalculateHours(); }

private void CalculateHours() { hours = end.HasValue ? (decimal?)(end.Value - start).TotalHours : null; Notify("Hours"); }

public override string ToString() { return description; } }

[Serializable] public class CommentDN : EmbeddedEntity { string text; public string Text { get { return text; } set { Set(ref text, value, "Text"); } }

DateTime date; public DateTime Date { get { return date; } set { Set(ref date, value, "Date"); } }

IBugDiscoverer writer; public IBugDiscoverer Writer { get { return writer; } set { Set(ref writer, value, "Writer"); } }

public override string ToString() { return "{0}: {1}".Formato(writer, text); } }

public enum Status { Open, Fixed, Rejected, }

[Serializable] public class ProjectDN : Entity { string name; public string Name { get { return name; } set { Set(ref name, value, "Name"); } }

bool isInternal; public bool IsInternal { get { return isInternal; } set { Set(ref isInternal, value, "IsInternal"); } }

public override string ToString() { return name + (isInternal ? " [Internal]" : ""); } }

[ImplementedBy(typeof(CustomerDN), typeof(DeveloperDN))] public interface IBugDiscoverer: IIdentifiable {

}

[Serializable] public class DeveloperDN : Entity, IBugDiscoverer { string name; public string Name { get { return name; } set { Set(ref name, value, "Name"); } }

public override string ToString() { return name; } }

[Serializable] public class CustomerDN : Entity, IBugDiscoverer { string name; public string Name { get { return name; } set { Set(ref name, value, "Name"); } }

public override string ToString() { return name; } }

Diagrams

The Visual Studio Class Designer diagram and the Sql Server Diagram of the equivalent tables above. Note there's some inaccuracy in the relationship from bug to project. The relationship is actually to Lazy<ProyeectDN> but the support of Class Designer to generics is very limited.

Image

Some Data



Finally, we normalized and inserted the following data in the database:

Image
Creative Commons License Signum Framework Site by Signum Software is licensed under a Creative Commons Attribution 3.0 License.
Powered by ScrewTurn Wiki version 3.0.5.600.