Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullReferenceException when syncing tables in non 'dbo' schema #7

Open
ai-2013 opened this issue Sep 30, 2014 · 1 comment
Open

NullReferenceException when syncing tables in non 'dbo' schema #7

ai-2013 opened this issue Sep 30, 2014 · 1 comment

Comments

@ai-2013
Copy link

ai-2013 commented Sep 30, 2014

Hi,
i am trying to publish a table named "Visits" belonging to a schema named "Jobs". Using the sync provisioning utility i have created a new scope with both the "Is template Scope" and "Enable Build Apply Procedures" checked. following is the code from the config file:

<SyncScope Name="MyFilteredScope" SchemaName="Jobs" IsTemplateScope="true" EnableBulkApplyProcedures="true">
<SyncTables>
<SyncTable Name="[Jobs].[Visits]" GlobalName="" SchemaName="" IncludeAllColumns="true" FilterClause="[side].CallSign = @callsign">
<SyncColumns>
<SyncColumn Name="VisitID" GlobalName="" SqlType="uniqueidentifier" IsPrimaryKey="true" IsNullable="false" />
<SyncColumn Name="StatusID" GlobalName="" SqlType="tinyint" IsPrimaryKey="false" IsNullable="false" />
<SyncColumn Name="Date" GlobalName="" SqlType="datetime" IsPrimaryKey="false" IsNullable="true" />
<SyncColumn Name="Name" GlobalName="" SqlType="nvarchar" IsPrimaryKey="false" IsNullable="true" />
<SyncColumn Name="PolicyID" GlobalName="" SqlType="nvarchar" IsPrimaryKey="false" IsNullable="true" />
<SyncColumn Name="Address" GlobalName="" SqlType="nvarchar" IsPrimaryKey="false" IsNullable="true" />
<SyncColumn Name="Notes" GlobalName="" SqlType="nvarchar" IsPrimaryKey="false" IsNullable="true" />
<SyncColumn Name="ContactName" GlobalName="" SqlType="nvarchar" IsPrimaryKey="false" IsNullable="true" />
<SyncColumn Name="EmailAddress" GlobalName="" SqlType="nvarchar" IsPrimaryKey="false" IsNullable="true" />
<SyncColumn Name="Telephone" GlobalName="" SqlType="nvarchar" IsPrimaryKey="false" IsNullable="true" />
<SyncColumn Name="CallSign" GlobalName="" SqlType="nvarchar" IsPrimaryKey="false" IsNullable="true" />
<SyncColumn Name="REPLICATE" GlobalName="" SqlType="bit" IsPrimaryKey="false" IsNullable="false" />
<SyncColumn Name="LocationID" GlobalName="" SqlType="nvarchar" IsPrimaryKey="false" IsNullable="true" />
<SyncColumn Name="Postcode" GlobalName="" SqlType="nvarchar" IsPrimaryKey="false" IsNullable="true" />
</SyncColumns>
<FilterColumns>
<FilterColumn Name="CallSign" />
</FilterColumns>
<FilterParameters>
<FilterParameter Name="@callsign" SqlType="nvarchar" DataSize="50" />
</FilterParameters>
</SyncTable>
</SyncTables>
</SyncScope>

When i provision the DB using the above config, a table named "Jobs.scope_config" is created with the following value under the "config_data" column:

<SqlSyncProviderScopeConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" IsTemplate="true">
<Adapter Name="[Jobs].[Visits]" GlobalName="[Jobs].[_[Visits]]" TrackingTable="[Jobs].[Visits_tracking]" SelChngProc="[Jobs].[Visits_selectchanges_d819f389-b493-40d5-adcc-0e95cdfa831d]" SelRowProc="[Jobs].[Visits_selectrow]" InsProc="[Jobs].[Visits_insert]" UpdProc="[Jobs].[Visits_update]" DelProc="[Jobs].[Visits_delete]" InsMetaProc="[Jobs].[Visits_insertmetadata]" UpdMetaProc="[Jobs].[Visits_updatemetadata]" DelMetaProc="[Jobs].[Visits_deletemetadata]" BulkTableType="[Jobs].[Visits_BulkType]" BulkInsProc="[Jobs].[Visits_bulkinsert]" BulkUpdProc="[Jobs].[Visits_bulkupdate]" BulkDelProc="[Jobs].[Visits_bulkdelete]" InsTrig="[Jobs].[Visits_insert_trigger]" UpdTrig="[Jobs].[Visits_update_trigger]" DelTrig="[Jobs].[Visits_delete_trigger]">
<Col name="VisitID" type="uniqueidentifier" param="@P_1" pk="true" />
<Col name="StatusID" type="tinyint" param="@P_2" />
<Col name="Date" type="datetime" null="true" param="@P_3" />
<Col name="Name" type="nvarchar" size="200" null="true" param="@P_4" />
<Col name="PolicyID" type="nvarchar" size="50" null="true" param="@P_5" />
<Col name="Address" type="nvarchar" size="500" null="true" param="@P_6" />
<Col name="Notes" type="nvarchar" size="max" null="true" param="@P_7" />
<Col name="ContactName" type="nvarchar" size="200" null="true" param="@P_8" />
<Col name="EmailAddress" type="nvarchar" size="200" null="true" param="@P_9" />
<Col name="Telephone" type="nvarchar" size="25" null="true" param="@P_10" />
<Col name="CallSign" type="nvarchar" size="50" null="true" param="@P_11" />
<Col name="REPLICATE" type="bit" param="@P_12" />
<Col name="LocationID" type="nvarchar" size="50" null="true" param="@P_15" />
<Col name="Postcode" type="nvarchar" size="8" null="true" param="@P_16" />
<FilterParam name="@callsign" />
<FilterClause>[side].CallSign = @callsign</FilterClause>
<FilterCol>CallSign</FilterCol>
</Adapter>
</SqlSyncProviderScopeConfiguration>

when I generate the server code the signature for class created for the publiched table is as follows:

[Microsoft.Synchronization.Services.SyncEntityTypeAttribute(TableGlobalName="Jobs__[Visits]", TableLocalName="[Jobs].[Visits]", KeyFields="VisitID")]
public partial class Jobs__[Visits] : MyFilteredScopeOfflineEntityBase {
//properties and variables have been removed
}

Inorder to compile the project i have to change the class name from "Jobs__[Visits]" to "Jobs__Visits" (note that i have to do a similar change in the SQLite client code generated). Here please note the value for the TableGlobalName, which is different from value stored in the Jobs.scope_config ([Jobs].[_[Visits]]).

Now when adding the filtering parameter what value should i provide for the tableName parameter, i.e. the 2nd parameter in the call to AddFilterParameterConfiguration? Running different combinations for the tableName parameters i am getting a NullReferenceException in "Microsoft.Synchronization.Services.SqlProvider.SqlSyncProviderService.CreateNewScopeForClient()" at the line

provisioning.Tables[param.TableName].FilterParameters[param.SqlParameterName].Value = param.Value;

in the above line of code the value for param.TableName is "Jobs__[Visits]" as provided to the AddFilterParameterConfiguration which in not found within the provisioning collection which contain the following values:

FilterClause: "[side].CallSign = @CallSign"
FilterColumns: Count = 1
FilterParameters: Count = 1
GlobalName: "[Jobs].[_[Visits].[]]"
LocalName: "[Jobs].[Visits]"
ObjectPrefix: ""
ObjectSchema: "Jobs"
UnquotedGlobalName: "Jobs._[Visits.]"
UnquotedLocalName: "Jobs.Visits"

i have reported the same issue here https://syncwinrt.codeplex.com/discussions/561695

@ai-2013 ai-2013 changed the title NullReferenceException when syncing tables in non 'dbo' schame NullReferenceException when syncing tables in non 'dbo' schema Sep 30, 2014
@Mimetis
Copy link
Owner

Mimetis commented Feb 4, 2015

Thx for the feedback !
During February, I will test this scenario. to be honest, I ve never test a complete solution with a schema.

Seb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants