Skip to content

Commit 37e1aa8

Browse files
Address inaccuracies in the code samples (SharePoint#5208)
1 parent 1ebed4a commit 37e1aa8

File tree

1 file changed

+32
-31
lines changed

1 file changed

+32
-31
lines changed

docs/general-development/get-started-using-the-client-object-model-with-external-data-in-sharepoint.md

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ ctx.Load(web);
108108
Entity entity = ctx.Web.GetEntity("http://sharepointservername", "EntityName");
109109
ctx.Load(entity);
110110
ctx.ExecuteQuery();
111-
112111
```
113112

114113

@@ -120,11 +119,28 @@ This example shows how to write a generic invoker so that you can create an enti
120119

121120

122121
```cs
123-
124-
ObjectCollection myObj;
125-
entity.Execute("MethodInstanceName", lsi, myObj);
126-
ctx.Load(myObj);
127-
ctx.ExecuteQuery();
122+
LobSystem lobSystem = entity.GetLobSystem();
123+
ctx.Load(lobSystem);
124+
125+
LobSystemInstanceCollection lobInstances = lobSystem.GetLobSystemInstances();
126+
ctx.Load(lobInstances);
127+
ctx.ExecuteQuery();
128+
129+
LobSystemInstance lsi;
130+
foreach(LobSystemInstance lobInstance in lobInstances)
131+
{
132+
if (lobInstance.Name.CompareTo("MyLOBSystemInstance") == 0)
133+
{
134+
lsi = lobInstance;
135+
}
136+
}
137+
138+
if (null != lsi)
139+
{
140+
entity.Execute("MethodInstanceName", lsi, Array.Empty<object>());
141+
ctx.Load(myObj);
142+
ctx.ExecuteQuery();
143+
}
128144

129145
```
130146

@@ -142,21 +158,12 @@ The following example shows how to retrieve a filtered, paged dataset. In this c
142158
FilterCollection fCollection = entity.GetFilters("methodName");
143159
ctx.Load(fCollection);
144160
ctx.ExecuteQuery();
145-
FilterCollection modifiedFCollection = new FilterCollection();
146-
foreach( Filter filter in fCollection)
147-
{
148-
if( filter.FilterField.equals("X.Y.Z.Country"))
149-
{
150-
filter.FilterValue = "India";
151-
modifiedFCollection.Add(Filter);
152-
}
153-
if(filter.FilterType == FilterType.Limit)
154-
{
155-
filter.FilterValue = 50;
156-
modifiedFCollection.Add(Filter);
157-
}
158-
}
159-
EntityInstanceCollection eCollection = entity.FindFiltered(modifiedFCollection,
161+
162+
fCollection.SetFilterValue("X.Y.Z.Country", 0, "India")
163+
// Assuming that the "RowLimit" filter has the Limit filter type
164+
fCollection.SetFilterValue("RowLimit", 0, 50)
165+
166+
EntityInstanceCollection eCollection = entity.FindFiltered(fCollection,
160167
"nameOfFinder", lsi);
161168
ctx.ExecuteQuery();
162169

@@ -176,16 +183,10 @@ The following example demonstrates how to return a filtered result set. In this
176183
FilterCollection fCollection = entity.GetFilters("methodName");
177184
ctx.Load(fCollection);
178185
ctx.ExecuteQuery();
179-
FilterCollection modifiedFCollection = new FilterCollection();
180-
foreach( Filter filter in fCollection)
181-
{
182-
if( filter.FilterField.equals("X.Y.Z.Country"))
183-
{
184-
filter.FilterValue = "India";
185-
modifiedFCollection.Add(Filter);
186-
}
187-
}
188-
EntityInstanceCollection eCollection = entity.FindFiltered(modifiedFCollection,
186+
187+
fCollection.SetFilterValue("X.Y.Z.Country", 0, "India")
188+
189+
EntityInstanceCollection eCollection = entity.FindFiltered(fCollection,
189190
"nameOfFinder", lsi);
190191
ctx.ExecuteQuery();
191192

0 commit comments

Comments
 (0)