Recuperando ultimo ID
04/05/2010
0
Galera...
tenho esta classe de cliente:
class Cliente
{
public int ClienteID { get; set; }
public string NomeCliente { get; set; }
public DateTime NascimentoCliente { get; set; }
public char SexoCliente { get; set; }
}
tenho uma collection desta classe:
class ClienteCollection : List
{
public List Cliente()
{
var dados = from c in this.ToList() select c;
var clientes = dados;
return clientes.ToList();
}
public List UltimoID()
{
var q1 = from c in this.ToList()
where (c.ClienteID == ( from l in this.ToList() select l.ClienteID).Max() )
select c;
return q1.ToList();
}
public List PrimeiroID()
{
var q1 = from c in this.ToList()
where (c.ClienteID == (from l in this.ToList() select l.ClienteID).Min())
select c;
return q1.ToList();
}
public List TodosCli()
{
var q1 = from c in this.ToList() select c;
return q1.ToList();
}
public List IdInserido(int ID)
{
var q1 = from c in this.ToList()
where c.ClienteID == ID
select c;
return q1.ToList();
}
Como posso fazer para retorna o ultimo ID do cliente, por exemplo:
public int MaxId()
{
return valor;
}
Alguem pode me ajudar com isso?
Obrigado!!!
tenho esta classe de cliente:
class Cliente
{
public int ClienteID { get; set; }
public string NomeCliente { get; set; }
public DateTime NascimentoCliente { get; set; }
public char SexoCliente { get; set; }
}
tenho uma collection desta classe:
class ClienteCollection : List
{
public List Cliente()
{
var dados = from c in this.ToList() select c;
var clientes = dados;
return clientes.ToList();
}
public List UltimoID()
{
var q1 = from c in this.ToList()
where (c.ClienteID == ( from l in this.ToList() select l.ClienteID).Max() )
select c;
return q1.ToList();
}
public List PrimeiroID()
{
var q1 = from c in this.ToList()
where (c.ClienteID == (from l in this.ToList() select l.ClienteID).Min())
select c;
return q1.ToList();
}
public List TodosCli()
{
var q1 = from c in this.ToList() select c;
return q1.ToList();
}
public List IdInserido(int ID)
{
var q1 = from c in this.ToList()
where c.ClienteID == ID
select c;
return q1.ToList();
}
Como posso fazer para retorna o ultimo ID do cliente, por exemplo:
public int MaxId()
{
return valor;
}
Alguem pode me ajudar com isso?
Obrigado!!!
Fernando /@ftremonti
Curtir tópico
+ 0
Responder
Posts
05/05/2010
Tiago Melantonio
public int MaxId()
{
return this.TodosCli().Max();
}
{
return this.TodosCli().Max();
}
Responder
Clique aqui para fazer login e interagir na Comunidade :)