var vw = database.GetExistingView (tpTitulo);
qry = vw.CreateQuery ();
qry.IndexUpdateMode = IndexUpdateMode.Never;
lines = qry.Run ();
foreach (var line in lines) {
var telefone = (JArray)line.Document.GetProperty ("fone");
objListaTelefonica.Add (new Cadastro () {
Nome = line.Document.GetProperty ("nome").ToString (),
Razao = line.Document.GetProperty ("razao").ToString (),
Logradouro = line.Document.GetProperty ("logradouro").ToString (),
Nr = line.Document.GetProperty ("nr").ToString (),
Complemento = line.Document.GetProperty ("complemento").ToString (),
Bairro = line.Document.GetProperty ("bairro").ToString (),
Cidade = line.Document.GetProperty ("cidade").ToString (),
Cep = line.Document.GetProperty ("cep").ToString (),
Produto = line.Document.GetProperty ("produto").ToString (),
Fone = telefone [0].Value<string> ("numero")
});
}
vwrestaurantes.SetMap ((document, emitter) => {
if ((document ["blativo"].ToString () == "1") && (document ["type"].ToString () == "E")) {
var titulos = (JArray)document ["titulos"];
for (int i = 0; i < titulos.Count; i++) {
if (ArrayTitulos.Any<string> ((Tools.RemoverAcentos (titulos [i].Value<string> ("descricao").ToLower ()).Trim ()).Equals)) {
emitter (Tools.RemoverAcentos (titulos [i].Value<string> ("descricao").ToLower ()).Trim (), document ["nome"]);
}
}
}
}, ver);
On Jan 26, 2015, at 2:34 PM, Julio Albuquerque <jcezar.al...@gmail.com> wrote:But it is not in query.Run () that should take? Not in query.Run () that runs the Map Function?
In line foreach (var line in lines) that will run the Map Function?
vwrestaurantes.SetMap ((document, emitter) => {
if ((document ["blativo"].ToString () == "1") && (document ["type"].ToString () == "E")) {
var titulos = (JArray)document ["titulos"];
for (int i = 0; i < titulos.Count; i++) {
if (titulos [i].Value<string> ("descricao").ToLower ().Equals ("LANCHERIAS")) {
emitter (titulos [i].Value<string> ("descricao").ToLower (), document ["nome"]);
}
}
}
}, ver);
foreach (var line in lines) {
var telefone = (JArray)line.Document.GetProperty ("fone");
objListaTelefonica.Add (new Cadastro () {
Nome = line.Document.GetProperty ("nome").ToString (),
Razao = line.Document.GetProperty ("razao").ToString (),
Logradouro = line.Document.GetProperty ("logradouro").ToString (),
Nr = line.Document.GetProperty ("nr").ToString (),
Complemento = line.Document.GetProperty ("complemento").ToString (),
Bairro = line.Document.GetProperty ("bairro").ToString (),
Cidade = line.Document.GetProperty ("cidade").ToString (),
Cep = line.Document.GetProperty ("cep").ToString (),
Produto = line.Document.GetProperty ("produto").ToString (),
Fone = telefone [0].Value<string> ("numero").ToString ()
});
}
On Jan 27, 2015, at 10:35 AM, Julio Albuquerque <jcezar.al...@gmail.com> wrote:This time (30 seconds) is being spent in the code below:
On Jan 27, 2015, at 10:59 AM, Julio Albuquerque <jcezar.al...@gmail.com> wrote:
His tips were brilliant!
How emiter multiple values with the platform I'm using? (Xamarin Studio Android and Couchbase Lite .Net)
vwMercados.SetMap ((document, emitter) => {
if ((document ["blativo"].ToString () == "1") && (document ["type"].ToString () == "E")) {
var titulos = (JArray)document ["titulos"];
for (int i = 0; i < titulos.Count; i++) {
if (titulos [i].Value<string> ("descricao").Equals ("MERCADOS E SUPERMERCADOS")) {
var Cad = new Cadastro ();
Cad.Nome = document ["nome"].ToString ();
Cad.Razao = document ["razao"].ToString ();
Cad.Bairro = document ["bairro"].ToString ();
Cad.Cep = document ["cep"].ToString ();
Cad.Cidade = document ["cidade"].ToString ();
Cad.Complemento = document ["complemento"].ToString ();
Cad.Logradouro = document ["logradouro"].ToString ();
Cad.Nr = document ["nr"].ToString ();
Cad.Produto = document ["produto"].ToString ();
Cad.Fone = document ["fone"].ToString ();
emitter (titulos [i].Value<string> ("descricao"), Cad);
}
}
}
}, ver);
private void carrega (out List<Cadastro> obj)
{
var vw = database.GetExistingView (tpTitulo);
qry = vw.CreateQuery ();
qry.IndexUpdateMode = IndexUpdateMode.Never;
lines = qry.Run ();
var lstRetorno = new List<Cadastro> (lines.Count);
for (int i = 0; i < lines.Count; i++) {
var Cad = JObject.Parse (lines.GetRow (i).Value.ToString ());
//var telefone = (JArray)Cad.Fone;
lstRetorno.Add (new Cadastro () {
Nome = Cad.Property ("Nome").Value.ToString (),
Razao = Cad.Property ("Razao").Value.ToString (),
Logradouro = Cad.Property ("Logradouro").Value.ToString (),
Nr = Cad.Property ("Nr").Value.ToString (),
Complemento = Cad.Property ("Complemento").Value.ToString (),
Bairro = Cad.Property ("Bairro").Value.ToString (),
Cidade = Cad.Property ("Cidade").Value.ToString (),
Cep = Cad.Property ("Cep").Value.ToString (),
Produto = Cad.Property ("Produto").Value.ToString ()
//Fone = telefone [0].Value<string> ("numero").ToString ()
});
}
obj = lstRetorno.GroupBy (s => s.Nome).Select (s => s.First ()).OrderBy (o => o.Nome).ToList<Cadastro> ();
}