Click here to Skip to main content
15,921,179 members
Home / Discussions / C#
   

C#

 
AnswerRe: How did you learn to program? Pin
User 171649213-Dec-06 12:55
professionalUser 171649213-Dec-06 12:55 
AnswerRe: How did you learn to program? Pin
Nader Elshehabi13-Dec-06 20:07
Nader Elshehabi13-Dec-06 20:07 
AnswerRe: How did you learn to program? Pin
Hamid_RT13-Dec-06 20:27
Hamid_RT13-Dec-06 20:27 
GeneralRe: How did you learn to program? Pin
Colin Angus Mackay13-Dec-06 21:35
Colin Angus Mackay13-Dec-06 21:35 
GeneralRe: How did you learn to program? Pin
Hamid_RT13-Dec-06 22:20
Hamid_RT13-Dec-06 22:20 
AnswerRe: How did you learn to program? Pin
SpartanSoft14-Dec-06 9:03
SpartanSoft14-Dec-06 9:03 
QuestionObject Factories with Lazy Loading in C# Pin
cebyrjoe213-Dec-06 10:46
cebyrjoe213-Dec-06 10:46 
AnswerRe: Object Factories with Lazy Loading in C# Pin
Colin Angus Mackay13-Dec-06 11:22
Colin Angus Mackay13-Dec-06 11:22 
cebyrjoe2 wrote:
The idea is, to have a kind of object factory, which will be responsible for creating my entity objects.
When a property of such an object is accesed and it is not yet loaded, the factory
(or a magic watcher) will be able to pause the execution flow for a while (maybe that step is not necessary)
load the missing data (don't know how to specify, from where to load that data----maybe via attributes) and
return to the flow.


Have you considered using properties?

public class MyClass
{
    private bool isLazyLoaded;
    private string someData;
 
    public string SomeData
    {
        get
        {
            DoLazyLoadIfNecessary();
            return this.someData;
        }
    }
 
    private void DoLazyLoadIfNecessary()
    {
        if (!isLazyLoaded)
        {
            // Do what ever is necessary to get the values.
        } 
    }
}
Once you have this only the code that does the lazy load will access the lazy loaded fields directly. Everything else goes through the property.


cebyrjoe2 wrote:
My entity objects, do not have a possibility to load the missing data by themselves, because they
are only data containers having private members, which are accessible via public properties.
These objects need to be filled with their data from outside, and therefore many lazy loading solutions
won't work here.


I should have read the whole thing before typing out that example - Sod it, I've typed it now so I'm keeping it! Big Grin | :-D

Each object will need to know at least an ID so that it can go and request its data from a DAL or some such thing.

Many of my objects have lazy load functionality, when they are created all that is known about them is a corresponding database ID. For any lazy load solution to work some sort of identifier needs to be known.


Upcoming Scottish Developers events:
* Glasgow: Tell us what you want to see in 2007


My: Website | Blog | Photos

Question[Message Deleted] Pin
R_L_H13-Dec-06 9:49
R_L_H13-Dec-06 9:49 
AnswerRe: How do you programmatically restart a Service? (specifically SQL Server) Pin
Colin Angus Mackay13-Dec-06 11:29
Colin Angus Mackay13-Dec-06 11:29 
GeneralRe: How do you programmatically restart a Service? (specifically SQL Server) Pin
navyjax224-Dec-08 13:14
navyjax224-Dec-08 13:14 
AnswerRe: How do you programmatically restart a Service? (specifically SQL Server) Pin
Andy Brummer13-Dec-06 11:37
sitebuilderAndy Brummer13-Dec-06 11:37 
QuestionResize row height in DataGrid (Pocket PC)? Pin
george ivanov13-Dec-06 7:17
george ivanov13-Dec-06 7:17 
Questionwin form datagridview sort by column Pin
fmardani13-Dec-06 6:07
fmardani13-Dec-06 6:07 
AnswerRe: win form datagridview sort by column Pin
Milky Way13-Dec-06 10:17
Milky Way13-Dec-06 10:17 
QuestionUnable to Deserialize - [cannot find an Assembly ] Pin
Eytukan13-Dec-06 5:48
Eytukan13-Dec-06 5:48 
AnswerRe: Unable to Deserialize - [cannot find an Assembly ] Pin
Karthik Kalyanasundaram13-Dec-06 6:03
Karthik Kalyanasundaram13-Dec-06 6:03 
GeneralRe: Unable to Deserialize - [cannot find an Assembly ] Pin
Eytukan13-Dec-06 18:05
Eytukan13-Dec-06 18:05 
QuestionDataTable.AcceptChanges Pin
wasife13-Dec-06 5:19
wasife13-Dec-06 5:19 
AnswerRe: DataTable.AcceptChanges Pin
Andrew Rissing13-Dec-06 7:23
Andrew Rissing13-Dec-06 7:23 
QuestionWriting to an access database with credentials Pin
Beaumont113-Dec-06 4:28
Beaumont113-Dec-06 4:28 
AnswerRe: Writing to an access database with credentials Pin
led mike13-Dec-06 6:39
led mike13-Dec-06 6:39 
GeneralRe: Writing to an access database with credentials Pin
Beaumont113-Dec-06 7:11
Beaumont113-Dec-06 7:11 
GeneralRe: Writing to an access database with credentials Pin
led mike13-Dec-06 7:22
led mike13-Dec-06 7:22 
GeneralRe: Writing to an access database with credentials Pin
Beaumont113-Dec-06 7:24
Beaumont113-Dec-06 7:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.