У меня есть БД SQL Server с столбцом идентификаторов int (IdProspecto), который автоматически увеличивается и используется в качестве первичного ключа для связи с другими таблицами в БД.Сейчас я создаю приложение Xamarin с использованием таблиц Azure Easy.У меня проблемы с синхронизацией с этим столбцом:
"Невозможно обновить столбец идентификаторов 'IdProspecto'".
Возможные решения, которые я рассматриваю: 1. ИзменитьIdProspecto от autonumeric int до Guid, и используйте это поле в качестве идентификатора, который требуется для простой таблицы.(это требует много изменений в моей БД) 2. Избегайте, чтобы обновление включало набор IdProspecto, когда я использую:
await this.prospectosTable.PullAsync("allProspectos", this.prospectosTable.CreateQuery());
Возможно ли это?(Но мне нужно ПОЛУЧИТЬ это значение, чтобы использовать его для связывания новых записей связанных таблиц.) Какое самое простое решение?
Это модель:
using System;
using Microsoft.WindowsAzure.MobileServices;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Text;
namespace MobileAppVaniplas
{
public class Prospectos
{
string id;
string empresa;
string tipoCliente;
string gerente;
string contacto;
string cargoContacto;
string ciudad;
string telefono1;
string telefono2;
string celular;
string direccion;
string email;
string paginaweb;
string calendarioColegio;
string observaciones;
string estado;
string prioridad;
DateTime fechaCreacion;
string creadoPor;
[JsonProperty(PropertyName = "id")]
public string Id
{
get { return id; }
set { id = value; }
}
[JsonProperty(PropertyName = "idProspecto")]
public string IdProspecto //Mayusculas segun BD
{
get { return idProspecto; }
set { idProspecto = value; }
}
[Version]
public string Version { get; set; }
[JsonProperty(PropertyName = "tipoCliente")]
public string TipoCliente
{
get { return tipoCliente; }
set { tipoCliente = value; }
}
[JsonProperty(PropertyName = "empresa")]
public string Empresa
{
get { return empresa; }
set { empresa = value; }
}
[JsonProperty(PropertyName = "gerente")]
public string Gerente
{
get { return gerente; }
set { gerente = value; }
}
[JsonProperty(PropertyName = "contacto")]
public string Contacto
{
get { return contacto; }
set { contacto = value; }
}
[JsonProperty(PropertyName = "cargoContacto")]
public string CargoContacto
{
get { return cargoContacto; }
set { cargoContacto = value; }
}
[JsonProperty(PropertyName = "ciudad")]
public string Ciudad
{
get { return ciudad; }
set { ciudad = value; }
}
[JsonProperty(PropertyName = "telefono1")]
public string Telefono1
{
get { return telefono1; }
set { telefono1 = value; }
}
[JsonProperty(PropertyName = "telefono2")]
public string Telefono2
{
get { return telefono2; }
set { telefono2 = value; }
}
[JsonProperty(PropertyName = "celular")]
public string Celular
{
get { return celular; }
set { celular = value; }
}
[JsonProperty(PropertyName = "direccion")]
public string Direccion
{
get { return direccion; }
set { direccion = value; }
}
[JsonProperty(PropertyName = "email")]
public string eMail
{
get { return email; }
set { email = value; }
}
[JsonProperty(PropertyName = "paginaweb")]
public string paginaWEB
{
get { return paginaweb; }
set { paginaweb = value; }
}
[JsonProperty(PropertyName = "calendarioColegio")]
public string CalendarioColegio
{
get { return calendarioColegio; }
set { calendarioColegio = value; }
}
[JsonProperty(PropertyName = "observaciones")]
public string Observaciones
{
get { return observaciones; }
set { observaciones = value; }
}
[JsonProperty(PropertyName = "estado")]
public string Estado
{
get { return estado; }
set { estado = value; }
}
[JsonProperty(PropertyName = "prioridad")]
public string Prioridad
{
get { return prioridad; }
set { prioridad = value; }
}
[JsonProperty(PropertyName = "fechaCreacion")]
public DateTime FechaCreacion
{
get { return fechaCreacion; }
set { fechaCreacion = value; }
}
[JsonProperty(PropertyName = "creadoPor")]
public string CreadoPor
{
get { return creadoPor; }
set { creadoPor = value; }
}
}
}
И этоэто функция, которую я использую для синхронизации:
public async Task SyncAsync()
{
ReadOnlyCollection<MobileServiceTableOperationError> syncErrors = null;
try
{
await this.client.SyncContext.PushAsync();
await this.prospectosTable.PullAsync("allProspectos", this.prospectosTable.CreateQuery());
}
catch (MobileServicePushFailedException exc)
{
if (exc.PushResult != null)
{
syncErrors = exc.PushResult.Errors;
}
}