0

I am having a set of 15 tables all of which are connected via some key to each other.

lets take 3 tables as example

table 1
id
f1
f2

table 2
id
table1_id
f3
f4

table 3
id
table2_id
f5
f6

where table1_id,table2_id are foreign keys.

Now I want to create a form with set of text boxes as : f1 f2 f3 f4 f5 f6.

is there a simple association that I can make with the text boxes so that on the click of ok button f1 f2 goes to table 1 and then f3 f4 goes to table 2 along with the table1_id etc ?

Its a desktop app.

3
  • Windows Forms or WPF? Also, if I understand your question correctly, you want the data in the TextBoxs' to go to the appropriate tables, based on which key? It looks like you have a daisy chain of 15 tables, with table 1 related to table 2, table 2 related to table 3, etc, correct? Commented Aug 20, 2011 at 2:42
  • not exactly daisy chain.. its like a network.. the relation is by the foreign_key.. table1_id etc Commented Aug 20, 2011 at 5:29
  • its windows forms , and yes you are correct at understanding my question Commented Aug 20, 2011 at 5:34

1 Answer 1

2

You don't specify which data access framework you use, but if you're willing to look at EF, it can map an entity to multiple tables, so you could model your form data as such.

Look at this:

http://msdn.microsoft.com/en-us/library/cc716698.aspx

Cheers

Sign up to request clarification or add additional context in comments.

4 Comments

so basically I must make entity data model ? and then it will generate tables.. cool.. I'll try and come back .. thanks. May be I am very weak at .net then.. working on ROR made me lazy.. :P
You don't have to use a model, but it does simplify your life considerably. I'd strongly recommend decoupling your UI implementation from your storage, where possible.
Yeah I do it in ROR .. But I am new to these things in .Net
Using a "model" to which you bind some of/all your UI controls on the form is a good thing. Even for trivial forms, I try to implement some kind of model. This way I benefit from databinding. In your case the benefit is that the "model" (an EF Entity) will know how to map itself back to your tables. And you have databinding :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.