Q: Saving collections.

  • Thread starter Thread starter Martin Arvidsson
  • Start date Start date
M

Martin Arvidsson

Hi!

Got a question, don't know if it's the right forum, but i will give it a
try.

I am building a CRM system for a customer, who has special needs.

On a task i want to be able to bind multiple contacts, like in outlook.

I use a collection of objects on the task to assign the contacts. Now i want
to store them along with the task in the database. Is there a good way to do
this or, simply have a detail table with the typ of collection and pointer
to that record?

Hmm, sorry for my bad english, i am from sweden, but i hope you get what i
want to do...

Regards

Martin Arvidson
 
Martin,

You could serialize the collection and then store that in the database.
However, that will prevent you from being able to query on properties in the
database. You would have to completely load the collection/instance if you
wanted to filter on it.

This is where you need to decide what your needs are in terms of
manipulating the data on the db side.

Hope this helps.
 
Thanx,

but I am not yet an expert in C#, any hint in where to look for an "ahhh"
experience?

Regards

Martin
Nicholas Paldino said:
Martin,

You could serialize the collection and then store that in the database.
However, that will prevent you from being able to query on properties in
the database. You would have to completely load the collection/instance
if you wanted to filter on it.

This is where you need to decide what your needs are in terms of
manipulating the data on the db side.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Martin Arvidsson said:
Hi!

Got a question, don't know if it's the right forum, but i will give it a
try.

I am building a CRM system for a customer, who has special needs.

On a task i want to be able to bind multiple contacts, like in outlook.

I use a collection of objects on the task to assign the contacts. Now i
want to store them along with the task in the database. Is there a good
way to do this or, simply have a detail table with the typ of collection
and pointer to that record?

Hmm, sorry for my bad english, i am from sweden, but i hope you get what
i want to do...

Regards

Martin Arvidson
 
Hello Martin!

Martin i cant see any reason why you should need to persist your
task-customer collection in the database as a whole. Since this
approach will not allow you to query the contacts based on its
attributes and will do bad for the reporting purpose as well (since you
will be needing a lot of reporting incase of CRM)

Best approach will be to cater this scenario like any other 1-* case
like a simple "order-orderline case", where you have a order table and
orderline table and the orderline table holds key to its parent. On
object level it will simply be implemented by having an Order
object/bean composing (basic-composition) IList of OrderLine objects.
Then build a OrderManager which will cater the CRUD
(Create/Read/Update/Delete) task of your order and orderline beans.

For you case replace order with task and orderline with contacts. This
is the way 1-* relation are normally handled in applications and for a
CRM like enterprise application you need to adopt a de-normalize
approach (untill and unless you have some special requirements)

If you have very special need for it to really really "only be
serialized" then you need to mark the task object and the contact
object in your collection to be "[Serializable]" and then serialize
them and save them in db.

Hope this might be of some help.

Let me know in case of any inconsistancy.

Have a good day.

Regards,

Moiz Uddin Shaikh
Software Engineer
Kalsoft (Pvt) Ltd
 
Back
Top