A
apoc69
hi people,
i got stucked in my project and i just dont know how to continue.
it's about puting business entities into the UI (web).
first some simple example code how an entity looks like in my project:
public class Person : Entity
{
string firstName;
string lastName;
public Person( string firstName, string lastName )
{
this.firstName = firstName;
this.lastName = lastName;
}
[EntityMemberAttribute( UINotation = "Firstname", MaxLength = 64)]
public string FirstName
{
get { return this.firstName; }
set { base.MarkDirty(); this.firstName = value; }
}
[EntityMemberAttribute( UINotation = "Lastname", MaxLength = 64)]
public string LastName
{
get { return this.lastName ; }
set { base.MarkDirty(); this.lastName = value; }
}
}
in the UI i have this code to populate that entity:
// Get all people who have an "e" in their name
EntityCollection persons =
SessionFactory.PersonSession.FindByName("e");
// Create a new webtable, set the entity collection
// as its datasource and bind
EntityWebTable webTable = new EntityWebTable();
webTable.DataSource = persons;
webTable.DataBind();
voila! an aspx page just shows me a pretty nice table, with captions (
UINotation flag in the entity ) and the persons itself ( firstname,
lastname )
ok, quite simple, isnt?
well, so far ok.. now i want to hide an field, let's say the first
name.
so i thoguht about creating an EntityView.
in that EntityView i could write something like this:
EntityView entityView = new EntityView( typeof ( Person ));
entityView["FirstName"].IsVisible = false;
webTable.DataView = entityView;
....but i dont like strong typed code like this, because if i change the
"FirstName" property in the Person entity, there wouldn't be any debug
error.
another solution would be, creating for each entity an own view. so for
the Person Entity, i would have to create a PersonView.. there i could
say:
personView.FirstName.IsVisible = false;
...but in that case, i would have to write for each entity an own view
class and if i add some new properties to an entity, i would have to
add them into the view too, and this would be pretty annoying doing
that each time. i also like to keep the "style" in the business logic (
like the notation, expressions, length );
i thought also about to change the entities itself, so if i use:
"person.FirstName" ..i would'nt get a string, i would get an object
with some other properties, something like this.
string firstName = person.firstName.Value.ToString();
bool isVisible = person.firstName.isVisible;
but personally i dont like that too..since the Value would have to be
an object, instead directly an string and this would also lead to many
many additional objects in memory.
hope somebody have some nice fresh ideas..
thanks.
steven wolf.
i got stucked in my project and i just dont know how to continue.
it's about puting business entities into the UI (web).
first some simple example code how an entity looks like in my project:
public class Person : Entity
{
string firstName;
string lastName;
public Person( string firstName, string lastName )
{
this.firstName = firstName;
this.lastName = lastName;
}
[EntityMemberAttribute( UINotation = "Firstname", MaxLength = 64)]
public string FirstName
{
get { return this.firstName; }
set { base.MarkDirty(); this.firstName = value; }
}
[EntityMemberAttribute( UINotation = "Lastname", MaxLength = 64)]
public string LastName
{
get { return this.lastName ; }
set { base.MarkDirty(); this.lastName = value; }
}
}
in the UI i have this code to populate that entity:
// Get all people who have an "e" in their name
EntityCollection persons =
SessionFactory.PersonSession.FindByName("e");
// Create a new webtable, set the entity collection
// as its datasource and bind
EntityWebTable webTable = new EntityWebTable();
webTable.DataSource = persons;
webTable.DataBind();
voila! an aspx page just shows me a pretty nice table, with captions (
UINotation flag in the entity ) and the persons itself ( firstname,
lastname )
ok, quite simple, isnt?
well, so far ok.. now i want to hide an field, let's say the first
name.
so i thoguht about creating an EntityView.
in that EntityView i could write something like this:
EntityView entityView = new EntityView( typeof ( Person ));
entityView["FirstName"].IsVisible = false;
webTable.DataView = entityView;
....but i dont like strong typed code like this, because if i change the
"FirstName" property in the Person entity, there wouldn't be any debug
error.
another solution would be, creating for each entity an own view. so for
the Person Entity, i would have to create a PersonView.. there i could
say:
personView.FirstName.IsVisible = false;
...but in that case, i would have to write for each entity an own view
class and if i add some new properties to an entity, i would have to
add them into the view too, and this would be pretty annoying doing
that each time. i also like to keep the "style" in the business logic (
like the notation, expressions, length );
i thought also about to change the entities itself, so if i use:
"person.FirstName" ..i would'nt get a string, i would get an object
with some other properties, something like this.
string firstName = person.firstName.Value.ToString();
bool isVisible = person.firstName.isVisible;
but personally i dont like that too..since the Value would have to be
an object, instead directly an string and this would also lead to many
many additional objects in memory.
hope somebody have some nice fresh ideas..
thanks.
steven wolf.