Where to create IEnumerable List?

doni49

Member
Joined
Mar 18, 2014
Messages
14
Programming Experience
10+
I am making what is basically an electronic checkbook app using Windows Forms.

I've created three new classes: Accounts, Transactions & Categories. I figured out HOW to use IEnumberable & LINQ statements to create a query that will search through all the transactions. And I also successfully bound that query to a DataGrid. But I know I didn't create these in the right "scope".

So now I'm trying to figure out the best place "scopewise" to create my List <T> objects. I also need to make them serializable so that I can write them out to a binary file.

TIA!
 
Well I was able to get it working (including the serialization). But I'm not sure if I did it the right way.

I opened the same file in which the main form (and all the child elements) is declared. I declared the accounts, transactions & categories variables at the top of the form class definition. Then the click event action for the dialog adds the data to these variables.
 
You should define a class to handle the data access and then make use of that class wherever it's needed. Under the circumstances, you might want to make that class implement the Singleton pattern.
 
Back
Top Bottom