Question

I need some help thinking about the design for my business objects. Our database records the daily entry and exit times for the comings and goings of the employees in our company. Each record also stores the UserID of the employee, the ID of the work station the employee signed in at and obviously the date.

A user can have many Entry and Exit times at any number of work stations at any given date. The record looks something like this:

SignInID | UserID | WorkStationID | DateTimeEntry | DateTimeExit

I have a reportviewer on my asp.net form that must display reports of this entry and exit data grouped by date, work station or user.

For example it must display all data for a specific date (and within that, ordered by work station).

enter image description here

Or it must display all data for a given work station (and within that, ordered by date) and other similar formats.

enter image description here

Until now I had a monstrosity of a method where I selected the data and constructed some kind of makeshift datatable to display on my form. I now want to redesign using objects, but I don't know how to design the hierarchy i.e. what object contains the collection of entry and exit times, and how to I make it flexible enough that I can query it (using Linq, perhaps?) based on the various display criteria?

I'm really interested in learning more about designing objects and using the correct terminology for what I'm trying to do, so if you can point me to some articles explaining these concepts it would be very helpful too.

EDIT: Okay, at least I've learned something new. What I'm trying to do is ORM - Object-relational mapping - and .NET has an inbuilt ORM tool called Entity Framework. So far so good. Now I have to see whether it can help me figure out how to organize my data.

Était-ce utile?

La solution

Well, I actually have to thank the community for not answering my question, because I got to learn a lot about Entity Framework, Linq (and its limitations with Entity Framework in .NET 3.5) and a whole bunch of other things to answer my own question.

What I ended up doing was create an Entity Model of my Database using Entity Framework and thus created the Business Objects I needed to organize my data. I learned that my data isn't designed in a hierarchy, rather there are associations such as Workstation and User that each time entry records contains. I used a Linq-to-Entities query to select the data I wanted and flattened it out using its associations (example Time.Workstation.Name or Time.User.FullName) so that in the end, my projected object contained all the data I wanted in each row of my report. My projected object was actually a POCO I created for the purpose of holding the queried data and making it available as a datasource for my rdlc report.

Finally I bound the results of my query to a Reportviewer's ObjectDataSource which connects to the rdlc file that I was able to define to my liking: i.e. Either displaying the Workstation first or the User, or whatever associated information I wanted to display.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top