<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tomblog &#187; Object Model</title>
	<atom:link href="http://tomblog.insomniacminds.com/tag/object-model/feed/" rel="self" type="application/rss+xml" />
	<link>http://tomblog.insomniacminds.com</link>
	<description>Rantings of an Insomniac Mind</description>
	<lastBuildDate>Tue, 15 Jun 2010 19:51:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>SharePoint Internals: SPList.GetItems</title>
		<link>http://tomblog.insomniacminds.com/2008/01/28/sharepoint-internals-splistgetitems/</link>
		<comments>http://tomblog.insomniacminds.com/2008/01/28/sharepoint-internals-splistgetitems/#comments</comments>
		<pubDate>Sun, 27 Jan 2008 23:48:03 +0000</pubDate>
		<dc:creator>Tombo</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[List]]></category>
		<category><![CDATA[Object Model]]></category>
		<category><![CDATA[View]]></category>

		<guid isPermaLink="false">http://tomblog.insomniacminds.com/2008/01/28/sharepoint-internals-splistgetitems/</guid>
		<description><![CDATA[SharePoint is build upon lists. These lists contain items. So the action to retrieve items from these lists is quite common. But when you&#8217;re coding against the object model. You might run into surprises. In the previous post I already talked about internal names and display names of fields. Today I&#8217;ll talk about an issue [...]]]></description>
			<content:encoded><![CDATA[<p>SharePoint is build upon lists. These lists contain items. So the action to retrieve items from these lists is quite common. But when you&#8217;re coding against the object model. You might run into surprises. In the previous post I already talked about internal names and display names of fields. Today I&#8217;ll talk about an issue when retrieving items from a list, and more specifially from a view.</p>
<p>When SharePoint is retrieving items from a list or view, SPList.GetItems is always called. This method will actually create a new collection of items. Those items will actually be retrieved by a query. To query in SharePoint we use a SPQuery object. This object is a container for SQL like queries. You select the fields you want to see, you have some conditions, a rowlimit, &#8230; And this is were a possible problem can reside. When retrieving items from a view, the query will only retrieve the fields defined in the SPView. In other words: the SPListItems you will get do not include all the data. This can be very confusing, as you expect a one-to-one relationship between the data of an object and the SPListItem. You should not forget however that the SPListItem is actually a proxy container for XML data. The object encapsulates the data for easy access and is not the actual full (logic) list item.</p>
<p>So how can we solve this? Well pretty easily actually. We create a real SPQuery object to retrieve our items with:</p>
<p><code>SPView view = myList.DefaultView;</p>
<p>   SPQuery query = new SPQuery();<br />
   query.Query = view.Query;</p>
<p>   SPListItemCollection myColl = myList.GetItems(query);<br />
</code><br />
Pretty easy, huh. The thing to remember here: SPListItem objects encapsulate XML data and are not the actual list items! Have a great week, everyone!</p>
]]></content:encoded>
			<wfw:commentRss>http://tomblog.insomniacminds.com/2008/01/28/sharepoint-internals-splistgetitems/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SharePoint Internals: InternalName versus DisplayName</title>
		<link>http://tomblog.insomniacminds.com/2008/01/25/sharepoint-internals-internalname-versus-displayname/</link>
		<comments>http://tomblog.insomniacminds.com/2008/01/25/sharepoint-internals-internalname-versus-displayname/#comments</comments>
		<pubDate>Fri, 25 Jan 2008 18:33:00 +0000</pubDate>
		<dc:creator>Tombo</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Object Model]]></category>

		<guid isPermaLink="false">http://tomblog.insomniacminds.com/2008/01/25/sharepoint-internals-internalname-versus-displayname/</guid>
		<description><![CDATA[When creating columns (more commonly called fields) in SharePoint through the interface, you have to enter a name for it. This name is used throughout the lists and sites, included internally. Except when you try to change the name, it&#8217;ll only reflect on the outside. Internally the old name will be kept. This is because [...]]]></description>
			<content:encoded><![CDATA[<p>When creating columns (more commonly called fields) in SharePoint through the interface, you have to enter a name for it. This name is used throughout the lists and sites, included internally. Except when you try to change the name, it&#8217;ll only reflect on the outside. Internally the old name will be kept. This is because a field has two names: an internal name and a display name. When creating a field, you set both. When renaming it, you only change the display name. (There is actually no way to change the internal name afterwards)<br />
<br />
But why is this a concern? Well, in the object model it can become quite vague when to use the internal name and when to use the display name. Here is a short list with some common methods and the name they need.</p>
<ul>
<li><strong>SPFieldCollection[name] </strong>: SPField<br />
  <em>name</em>: DisplayName<br />
  <em>unexistent</em>: exception</li>
<li><strong>SPFieldCollection.GetField(name)</strong> : SPField<br />
  name: internalName, displayName or internalName and displayName from the current context<br />
  unexistent: exception</li>
<li><strong>SPFieldCollection.GetFieldByInternalName(name)</strong> : SPField<br />
  <em>name</em>: internalName<br />
  <em>unexistent</em>: exception</li>
<li><strong>SPFieldCollection.ContainsField(name)</strong> : bool<br />
  name<em>: displayName or internalName<br />
  </em><em>unexistent</em>: boolean</li>
<li><strong>SPListItem[name]</strong> : object<br />
  <em>name</em>: internalName, displayName or internalName and displayName from the current context<br />
  <em>unexistent</em>: null</li>
<li><strong>SPListItem.GetFormattedValue(name)</strong> : string<br />
  <em>name</em>: internalName, displayName or internalName and displayName from the current context<br />
  <em>unexistent</em>: exception</li>
</ul>
<p>If I find more relevant functions, I will update this list. On a related note, there also exists a static name. This is a name used by the field type. This is different from the internal name, as the internal name must be unique in its list and could have changed.</p>
<p>Hope this clears up some confusion about field naming in SharePoint. See ya.</p>
]]></content:encoded>
			<wfw:commentRss>http://tomblog.insomniacminds.com/2008/01/25/sharepoint-internals-internalname-versus-displayname/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
