This post is part of an eight part series describing the process I have followed to be able create a BCS model capable of indexing well over 10 million items.
I created a number of stored procedures to be used to segment the data so we can take smaller bites of our huge elephant of data, stackoverflow.
Here's a representative entity describing the QuestionSegment Entity. There doesn't seem to be a good way to deal with the wide XML, so it's a bit ugly.
Here's the Question Entity:
<Entity Namespace="stackexchange.so" Version="1.1.0.0" EstimatedInstanceCount="10000" Name="Question" DefaultDisplayName="Question">
<Properties>
<Property Name="DefaultAction" Type="System.String">View Profile</Property>
</Properties>
<Identifiers>
<Identifier TypeName="System.Int32" Name="ID" />
</Identifiers>
<Methods>
<Method IsStatic="false" Name="usp_GetQuestionsBySegment AssociationNavigator">
<Properties>
<Property Name="BackEndObject" Type="System.String">usp_GetQuestionsBySegment</Property>
<Property Name="BackEndObjectType" Type="System.String">SqlServerRoutine</Property>
<Property Name="RdbCommandText" Type="System.String">usp_GetQuestionsBySegment</Property>
<Property Name="RdbCommandType" Type="System.Data.CommandType, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">StoredProcedure</Property>
<Property Name="Schema" Type="System.String">dbo</Property>
</Properties>
<FilterDescriptors>
<FilterDescriptor Type="Input" Name="LastCrawlTime">
<Properties>
<Property Name="CrawlStartTime" Type="System.String"></Property>
</Properties>
</FilterDescriptor>
</FilterDescriptors>
<Parameters>
<Parameter Direction="In" Name="@segmentNumber">
<TypeDescriptor TypeName="System.Int32" IdentifierName="segmentNumber"
IdentifierEntityName="QuestionSegment" IdentifierEntityNamespace="stackexchange.so"
ForeignIdentifierAssociationName="usp_GetQuestionsBySegment AssociationNavigator Instance"
Name="@segmentNumber" />
</Parameter>
<Parameter Direction="In" Name="@lastRunDate">
<TypeDescriptor TypeName="System.DateTime" AssociatedFilter="LastCrawlTime" Name="lastModifiedTime">
<Interpretation>
<NormalizeDateTime LobDateTimeMode="Local" />
</Interpretation>
</TypeDescriptor>
</Parameter>
<Parameter Direction="Return" Name="usp_GetQuestionsBySegment Return">
<TypeDescriptor TypeName="System.Data.IDataReader, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" IsCollection="true" Name="uv_AllQuestionsRead List">
<TypeDescriptors>
<TypeDescriptor TypeName="System.Data.IDataRecord, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Name="uv_AllQuestionsRead ListElement">
<TypeDescriptors>
<TypeDescriptor TypeName="System.Int32" ReadOnly="true" IdentifierName="ID" Name="ID" />
<TypeDescriptor TypeName="System.Nullable`1[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]" Name="ParentId" />
<TypeDescriptor TypeName="System.Nullable`1[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]" Name="AnswerCount" />
<TypeDescriptor TypeName="System.String" Name="Body">
<Interpretation>
<NormalizeString FromLOB="NormalizeToNull" ToLOB="NormalizeToEmptyString" />
</Interpretation>
</TypeDescriptor>
<TypeDescriptor TypeName="System.Nullable`1[[System.DateTime, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]" Name="ClosedDate">
<Interpretation>
<NormalizeDateTime LobDateTimeMode="UTC" />
</Interpretation>
</TypeDescriptor>
<TypeDescriptor TypeName="System.Nullable`1[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]" Name="CommentCount" />
<TypeDescriptor TypeName="System.Nullable`1[[System.DateTime, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]" Name="CommunityOwnedDate">
<Interpretation>
<NormalizeDateTime LobDateTimeMode="UTC" />
</Interpretation>
</TypeDescriptor>
<TypeDescriptor TypeName="System.DateTime" Name="CreationDate">
<Properties>
<Property Name="RequiredInForms" Type="System.Boolean">true</Property>
</Properties>
<Interpretation>
<NormalizeDateTime LobDateTimeMode="UTC" />
</Interpretation>
</TypeDescriptor>
<TypeDescriptor TypeName="System.Nullable`1[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]" Name="FavoriteCount" />
<TypeDescriptor TypeName="System.DateTime" Name="LastActivityDate">
<Properties>
<Property Name="RequiredInForms" Type="System.Boolean">true</Property>
</Properties>
<Interpretation>
<NormalizeDateTime LobDateTimeMode="UTC" />
</Interpretation>
</TypeDescriptor>
<TypeDescriptor TypeName="System.Nullable`1[[System.DateTime, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]" Name="LastEditDate">
<Interpretation>
<NormalizeDateTime LobDateTimeMode="UTC" />
</Interpretation>
</TypeDescriptor>
<TypeDescriptor TypeName="System.String" Name="LastEditorDisplayName">
<Properties>
<Property Name="Size" Type="System.Int32">40</Property>
</Properties>
<Interpretation>
<NormalizeString FromLOB="NormalizeToNull" ToLOB="NormalizeToNull" />
</Interpretation>
</TypeDescriptor>
<TypeDescriptor TypeName="System.Int32" Name="Score">
<Properties>
<Property Name="RequiredInForms" Type="System.Boolean">true</Property>
</Properties>
</TypeDescriptor>
<TypeDescriptor TypeName="System.String" Name="Tags">
<Properties>
<Property Name="Size" Type="System.Int32">150</Property>
</Properties>
<Interpretation>
<NormalizeString FromLOB="NormalizeToNull" ToLOB="NormalizeToNull" />
</Interpretation>
</TypeDescriptor>
<TypeDescriptor TypeName="System.String" Name="Title">
<Properties>
<Property Name="Size" Type="System.Int32">250</Property>
</Properties>
<Interpretation>
<NormalizeString FromLOB="NormalizeToNull" ToLOB="NormalizeToNull" />
</Interpretation>
</TypeDescriptor>
<TypeDescriptor TypeName="System.Int32" Name="ViewCount">
<Properties>
<Property Name="RequiredInForms" Type="System.Boolean">true</Property>
</Properties>
</TypeDescriptor>
<TypeDescriptor TypeName="System.String" Name="DisplayName">
<Properties>
<Property Name="Size" Type="System.Int32">40</Property>
</Properties>
<Interpretation>
<NormalizeString FromLOB="NormalizeToNull" ToLOB="NormalizeToNull" />
</Interpretation>
</TypeDescriptor>
<TypeDescriptor TypeName="System.String" Name="PostType">
<Properties>
<Property Name="Size" Type="System.Int32">50</Property>
</Properties>
<Interpretation>
<NormalizeString FromLOB="NormalizeToNull" ToLOB="NormalizeToNull" />
</Interpretation>
</TypeDescriptor>
<TypeDescriptor TypeName="System.Int32" Name="segmentNumber" />
</TypeDescriptors>
</TypeDescriptor>
</TypeDescriptors>
</TypeDescriptor>
</Parameter>
</Parameters>
<MethodInstances>
<Association Name="usp_GetQuestionsBySegment AssociationNavigator Instance" Type="AssociationNavigator" ReturnParameterName="usp_GetQuestionsBySegment Return">
<Properties>
<Property Name="DirectoryLink" Type="System.String"></Property>
<Property Name="ForeignFieldMappings" Type="System.String">
<?xml version="1.0" encoding="utf-16"?>
<ForeignFieldMappings xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ForeignFieldMappingsList>
<ForeignFieldMapping ForeignIdentifierName="segmentNumber" ForeignIdentifierEntityName="QuestionSegment" ForeignIdentifierEntityNamespace="stackexchange.so" FieldName="segmentNumber" />
</ForeignFieldMappingsList>
</ForeignFieldMappings>
</Property>
<Property Name="LastModifiedTimeStampField" Type="System.String">LastEditDate</Property>
<Property Name="UseClientCachingForSearch" Type="System.String"></Property>
</Properties>
<SourceEntity Namespace="stackexchange.so" Name="QuestionSegment" />
<DestinationEntity Namespace="stackexchange.so" Name="Question" />
</Association>
</MethodInstances>
</Method>
<Method IsStatic="false" Name="usp_getPostByID Question">
<Properties>
<Property Name="BackEndObject" Type="System.String">usp_getPostByID</Property>
<Property Name="BackEndObjectType" Type="System.String">SqlServerRoutine</Property>
<Property Name="RdbCommandText" Type="System.String">[dbo].[usp_getPostByID]</Property>
<Property Name="RdbCommandType" Type="System.Data.CommandType, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">StoredProcedure</Property>
<Property Name="Schema" Type="System.String">dbo</Property>
</Properties>
<Parameters>
<Parameter Direction="In" Name="@postID">
<TypeDescriptor TypeName="System.Nullable`1[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]" IdentifierName="ID" Name="@postID" />
</Parameter>
<Parameter Direction="Return" Name="usp_getPostByID">
<TypeDescriptor TypeName="System.Data.IDataReader, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" IsCollection="true" Name="usp_getPostByID">
<TypeDescriptors>
<TypeDescriptor TypeName="System.Data.IDataRecord, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Name="usp_getPostByIDElement">
<TypeDescriptors>
<TypeDescriptor TypeName="System.Int32" ReadOnly="true" IdentifierName="ID" Name="ID" />
<TypeDescriptor TypeName="System.Nullable`1[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]" Name="ParentId" />
<TypeDescriptor TypeName="System.Nullable`1[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]" Name="AnswerCount" />
<TypeDescriptor TypeName="System.String" Name="Body">
<Interpretation>
<NormalizeString FromLOB="NormalizeToNull" ToLOB="NormalizeToEmptyString" />
</Interpretation>
</TypeDescriptor>
<TypeDescriptor TypeName="System.Nullable`1[[System.DateTime, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]" Name="ClosedDate">
<Interpretation>
<NormalizeDateTime LobDateTimeMode="UTC" />
</Interpretation>
</TypeDescriptor>
<TypeDescriptor TypeName="System.Nullable`1[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]" Name="CommentCount" />
<TypeDescriptor TypeName="System.Nullable`1[[System.DateTime, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]" Name="CommunityOwnedDate">
<Interpretation>
<NormalizeDateTime LobDateTimeMode="UTC" />
</Interpretation>
</TypeDescriptor>
<TypeDescriptor TypeName="System.DateTime" Name="CreationDate">
<Interpretation>
<NormalizeDateTime LobDateTimeMode="UTC" />
</Interpretation>
</TypeDescriptor>
<TypeDescriptor TypeName="System.Nullable`1[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]" Name="FavoriteCount" />
<TypeDescriptor TypeName="System.DateTime" Name="LastActivityDate">
<Interpretation>
<NormalizeDateTime LobDateTimeMode="UTC" />
</Interpretation>
</TypeDescriptor>
<TypeDescriptor TypeName="System.Nullable`1[[System.DateTime, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]" Name="LastEditDate">
<Interpretation>
<NormalizeDateTime LobDateTimeMode="UTC" />
</Interpretation>
</TypeDescriptor>
<TypeDescriptor TypeName="System.String" Name="LastEditorDisplayName">
<Properties>
<Property Name="Size" Type="System.Int32">40</Property>
</Properties>
<Interpretation>
<NormalizeString FromLOB="NormalizeToNull" ToLOB="NormalizeToNull" />
</Interpretation>
</TypeDescriptor>
<TypeDescriptor TypeName="System.Int32" Name="Score" />
<TypeDescriptor TypeName="System.String" Name="Tags">
<Properties>
<Property Name="Size" Type="System.Int32">150</Property>
</Properties>
<Interpretation>
<NormalizeString FromLOB="NormalizeToNull" ToLOB="NormalizeToNull" />
</Interpretation>
</TypeDescriptor>
<TypeDescriptor TypeName="System.String" Name="Title">
<Properties>
<Property Name="Size" Type="System.Int32">250</Property>
</Properties>
<Interpretation>
<NormalizeString FromLOB="NormalizeToNull" ToLOB="NormalizeToNull" />
</Interpretation>
</TypeDescriptor>
<TypeDescriptor TypeName="System.Int32" Name="ViewCount" />
<TypeDescriptor TypeName="System.String" Name="DisplayName">
<Properties>
<Property Name="Size" Type="System.Int32">40</Property>
</Properties>
<Interpretation>
<NormalizeString FromLOB="NormalizeToNull" ToLOB="NormalizeToNull" />
</Interpretation>
</TypeDescriptor>
<TypeDescriptor TypeName="System.String" Name="PostType">
<Properties>
<Property Name="Size" Type="System.Int32">50</Property>
</Properties>
<Interpretation>
<NormalizeString FromLOB="NormalizeToNull" ToLOB="NormalizeToNull" />
</Interpretation>
</TypeDescriptor>
<TypeDescriptor TypeName="System.Nullable`1[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]" Name="AcceptedAnswerId" />
</TypeDescriptors>
</TypeDescriptor>
</TypeDescriptors>
</TypeDescriptor>
</Parameter>
</Parameters>
<MethodInstances>
<MethodInstance Type="SpecificFinder" ReturnParameterName="usp_getPostByID" ReturnTypeDescriptorPath="usp_getPostByID[0]" Default="true" Name="usp_getPostByID Question Instance">
<Properties>
<Property Name="LastDesignedOfficeItemType" Type="System.String">None</Property>
</Properties>
</MethodInstance>
</MethodInstances>
</Method>
</Methods>
<AssociationGroups>
<AssociationGroup Name="QuestionSegment-Question">
<AssociationReference AssociationName="usp_GetQuestionsBySegment AssociationNavigator Instance" Reverse="false" EntityNamespace="stackexchange.so" EntityName="Question" />
</AssociationGroup>
</AssociationGroups>
<Actions>
<Action Position="1" IsOpenedInNewWindow="false" Url="http://sp2013lab:80/sites/ECT/_bdc/stackexchange_so/Question_2.aspx?ID={0}" ImageUrl="/_layouts/15/1033/images/viewprof.gif" Name="View Profile">
<LocalizedDisplayNames>
<LocalizedDisplayName LCID="1033">View Profile</LocalizedDisplayName>
</LocalizedDisplayNames>
<Properties>
<Property Name="IsTaskpaneAction" Type="System.Boolean">true</Property>
<Property Name="Office Version" Type="System.String">15</Property>
</Properties>
<ActionParameters>
<ActionParameter Index="0" Name="ID[0]">
<Properties>
<Property Name="IdOrdinal" Type="System.Byte">0</Property>
</Properties>
</ActionParameter>
</ActionParameters>
</Action>
</Actions>
</Entity>