English 中文(简体)
Design issues with DTO s etc
原标题:
  • 时间:2009-11-25 12:33:52
  •  标签:
  • c#
  • dto

I am designing a web application in c# that mostly talks with the database. I have created a DTO for each table in the database. Now for each Table there is a custom table repository class that does all the saving and fetching pertaining to that particular table, and I m using stored procedures for that.

The issue is now some stored procedures will actually do a inner join operation and then send a custom output which is a combination of 2 tables.

Therefore I m not able to store the data in a single DTO object.

If there are any basic operations which are mostly done on a single table then things are fine.. I can call the table dto object for both inserts and fetching from the database. But when joins are there in stored procedures and during certain situations we update multiple tables.

How should we design the app?

Please Help

Thanks

最佳回答

Sounds like you may want to re-think having a DTO that directly corresponds to each table in the database.

Rather, a DTO should correspond to something logical in the real-world model that s used behind the Web site. So, for instance, a Customer object might have a collection of Order IDs within it, even though these would be logically stored in two tables in the database.

There is nothing wrong (in fact it s often essential) to have DTO referencing other DTOs, so for instance you could have a Customer class that points to a list of Address classes.

If things get more complex you will most likely want to consider introducing another layer at this point with true "domain objects" that map to your DTOs, which from the sound of it are "persistence objects".

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签