Autor Beitrag
csharpMorpheus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Mi 16.12.09 15:58 
Kann ich das erstellte Property um weitere Daten erweitern, sodass sogesehen mehr Daten drin sind?
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
public void crmNeuenDatensatzStapeln(string feldname, string feldwert)
        {
            StringProperty prop = new StringProperty();
            prop.Name = feldname;
            prop.Value = feldwert;

            this.dynEntity.Properties = new Property[] { prop };
        }



Wie der Funktionsname schon sagt will ich diese Funktion mehrmals ausführen mit immer unterschiedlichen Parametern die
ich übergebe und zum schluss führe ich die Funktion crmNeuenDatensatzSpeichern() aus und diese Funktion
benötigt dann alle gestapelten Propertys in der "thiy.dynEntity.Properties" !

Wie ergänze ich einen Property ?

Dankeschön
danielf
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1012
Erhaltene Danke: 24

Windows XP
C#, Visual Studio
BeitragVerfasst: Mi 16.12.09 16:11 
Bei Zeile 7 überschreibst du jedes mal den alten "Stapel".

Was du willst ist, dem Stapel was hinzuzufügen.
ausblenden C#-Quelltext
1:
this.dynEntity.Properties.Add( prop );					
csharpMorpheus Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Mi 16.12.09 16:23 
user profile icondanielf hat folgendes geschrieben Zum zitierten Posting springen:
Bei Zeile 7 überschreibst du jedes mal den alten "Stapel".

Was du willst ist, dem Stapel was hinzuzufügen.
ausblenden C#-Quelltext
1:
this.dynEntity.Properties.Add( prop );					


Es gibt dort kein ADD !
csharpMorpheus Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Do 17.12.09 15:48 
Kann mir niemand helfen?
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Do 17.12.09 16:32 
Kannst Du die Definiton von "Properties" ändern, also dass das von einem anderen Typ ist als ein Array?

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Ralf Jansen
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 4708
Erhaltene Danke: 991


VS2010 Pro, VS2012 Pro, VS2013 Pro, VS2015 Pro, Delphi 7 Pro
BeitragVerfasst: Do 17.12.09 18:15 
Wenn Properties zwingend ein Array sein muss, was äußerst unglücklich wäre für etwas das man dynamisch regelmäßig erweitern möchte, so bleibt dir keine anderer Weg als jedesmal eine neues Array zu erzeugen und alle alten Werte + den neuen hinzukopieren. Da würde ich dann als Zwischenschritt eine generische Liste nehmen um die alten Werte einfach in die Liste zu bekommen. Geschickter wäre es aber wenn dynEntity.Properties selbst bereits ein entsprechender Datentyp wäre und kein Array.

ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
StringProperty prop = new StringProperty();
prop.Name = feldname;
prop.Value = feldwert;

List<Property> properties = new List<string>(this.dynEntity.Properties);
properties.Add(prop)

this.dynEntity.Properties = properties.ToArray();