views:

33

answers:

1

I have 3 Tables in my database. Each table has 3 fields each, excluding the ID field. out of which 2 fields are of type nvarchar. None of the tables are related.

My ListView in the application helps the user to search my database, the search being incremental. The search includes the nvarchar fields of the 3 tables ie, 6 fields in total.

Eg:

  • PhoneBook: Name, PhoneNo
  • Notes: Title, Content
  • Bookmarks: Name, url

I've the models generated for the 3 tables.

Now the ListBox should display the Ph.Name, Title and the Bo.Name fields. ie, It should be bound to them. But they are from different models. I also should be able to perform CRUD operation on the item searched. How would i do that?

STILL AFTER ANSWERS:(

P.S: Separate ViewModels are created for each Model which are used for their respective views for handling those tables individually. But this is an integrated view where the user should be able to search everything.

Also please somebody suggest me a better Title for this question:)

A: 

Why not define an interface that is implemented by your three different models and have your view bind to the interface instead? You can support CRUD operations via the same interface too with each model implementing (or notifying a controller) as necessary.

Paul Sasik
My ListView should contain only one column. It should display all the 3 fields merged into one. Whenever i search for a phone number, the person's name has to be displayed in the listview and whenever i search for some NoteTitle, the Title itself should be displayed in the ListView's only column. Hope you got it.
Veer
In that case it sounds like you should just have one model that represents the three separate datasets. Of course your binding becomes a little interesting. Although the interface idea doesn't stand in the way of what you want to accomplish.
Paul Sasik