I'v e built a fundamental DAL which could retrieve data along with a businesslayer with several objects by using this DAL. After I planned the information in to the business objects and done something by using it, I should also write the information to the database. A few of the business objects have lots of qualities, so passing every worth of a company object as parameter to an approach to the related dataservice isn't a possibility.
Different ways I have been considering:
pass the company resist the the related data service, there perform SP with the values as parameters. - sucks, because I must pass a company resist the DAL (breaking the separation) and most likely finish track of SPs with >50 parameters
create a clear (?) dataset inside the business object, grow it using the values in the business object, pass that dataset towards the data service increase the db using a dataadapter. I figured of making a clear dataset having a "... WHERE "-SQL String. Would that be a sensible practice?
This is actually the very first time I actually do something similar to this. The second sounds easier to me, but maybe you will find other, better approaches? Or The first is much better for many reasons I'm not sure?
[edit:] I can not use LinQ2SQL, cuz I personally use C# Express (which only supports querying local DBs, while mine is really a remote one)
Pass your object to your DAL. In case your writting the DAL layer by hand your DAL layer ought to know how to consider an Entity and persist it towards the DB, and just how to come back an Entity in the database. The DAL is all about persistance of the organizations to some non-volatile medium.
You have not pointed out using LINQ. Is the fact that because you are not using .Internet 3.5 yet?
Also, it's not necessary to build your DAL that generic. The phone callers of the DAL aren't attempting to update all qualities from the business object, could they be? They most likely wish to update areas of it, which means you should produce an API that performs this. For example, they may would like to add a previous address to some Contact object, or even even update a telephone number. You must have a tradeoff between doing exactly what the caller is actually attempting to do, and the amount of separate techniques you'd need to be able to do this.
The DAL ought to be about mapping involving the business objects and also the specific data representation. For this reason the Repository pattern that actually works using the domain objects, enables you to definitely switch to another persistance implementation, that may not really be considered a database.
You're worried about requiring to pass through a lot of parameters towards the DAL's techniques, after which mention a good example in which you only have to pass two or three values. If that's the situation, passing it as being the method's arguments is affordable. If you're passing more values, one method for you to do it is as simple as determining an interface using the subset of values you need to save. By doing this you're indicating clearly the data that method is going to be handling.
No matter the above mentioned, don't result in the techniques too specific, while you would finish up with a lot of combinations that make it harder to mantain.
why do you consider that after passing a company resist the DAL you're breaking the separation. perhaps you should think on separating the bussines objects into another layer.
also you could attempt linq2SQL for the reason that method for you to ignore parameters and will also reduce the amount of your SP's.
Unless of course your computer data Access Layer is extremely generic, wouldso would passing a company object be bad?
I am a fan of serializing the item and passing the XML to some saved proc, but I'll most likely maintain the minority.