publicclassPessoa
{
[LSM.Generic.Repository.Attribute.DtMap("IdPessoa")] //Use this if the column name is different with the property , also in Generic.Repository.SqlServer will use this to generate procedure parameter namepublic intId { get; set; }
public stringNome { get; set; }
public stringSobreNome { get; set; }
public DateTimeDataNascimento { get; set; }
public boolAtivo { get; set; }
}
vardt = newDataTable();
List<Pessoa> list = DtMapper.DataTableToList<Pessoa>(dt);
List<Pessoa> list = DtMapper.DataTableToNullableList<Pessoa>(dt);
Pessoaobj = DtMapper.DataTableToObj<Pessoa>(dt);
Pessoaobj = DtMapper.DataRowToObj<Pessoa>(dt.Rows[0]);
Generic.Repository.SqlServer
[LSM.Generic.Repository.DataAnnotation.Procedure("GetPessoaById", "GetAllPessoa", "AddPessoa", "UpdatePessoa", "RemovePessoa")]
publicclassPessoa
{
[LSM.Generic.Repository.DataAnnotation.ProcedureGetByIdParameter]
[LSM.Generic.Repository.DataAnnotation.ProcedureUpdateParameter]
[LSM.Generic.Repository.DataAnnotation.ProcedureRemoveParameter]
[LSM.Generic.Repository.Attribute.DtMap("IdPessoa")] //Use this if the column name is different with the property , also in Generic.Repository.SqlServer will use this to generate procedure parameter namepublic intId { get; set; }
[LSM.Generic.Repository.DataAnnotation.ProcedureAddParameter]
[LSM.Generic.Repository.DataAnnotation.ProcedureUpdateParameter]
public stringNome { get; set; }
[LSM.Generic.Repository.DataAnnotation.ProcedureAddParameter]
[LSM.Generic.Repository.DataAnnotation.ProcedureUpdateParameter]
public stringSobreNome { get; set; }
[LSM.Generic.Repository.DataAnnotation.ProcedureAddParameter]
[LSM.Generic.Repository.DataAnnotation.ProcedureUpdateParameter]
public DateTimeDataNascimento { get; set; }
public boolAtivo { get; set; }
}
stringConexao = "Connection String";
using (var context = newLSM.Generic.Repository.SqlServer.DbContext<Pessoa>(Conexao))
{
for (inti = 0; i < 1000; i++)
{
varpessoa = newPessoa();
pessoa.Nome = "Nome " + i.ToString();
pessoa.SobreNome = "SobreNome " + i.ToString();
pessoa.DataNascimento = DateTime.Now.AddMonths(i);
pessoa.Ativo = true;
context.Add(pessoa);
}
varretorno = context.GetById(new Pessoa() { Id = 150 });
varLista = context.GetAll();
foreach (varitem in Lista.Where(i => i.Id <= 250))
{
item.Nome = item.Nome + " Alterado";
context.Update(item);
}
foreach (varitem in Lista.Where(i => i.Id <= 10))
{
context.Remove(item);
}
}
LSM.Generic.Mvc
MvcMapper.GetListOfSelectListItem
publicclassTodo
{
[Key]
public intId { get; set; }
[LabelForDropDown]
public stringName { get; set;
public string Code { get; set; }
}
varlist = newList<Todo>();
list.Add(new Todo() { Id = 1 , Name = "Todo 1" , Code = "T1" });
list.Add(new Todo() { Id = 2, Name = "Todo 2", Code = "T2" });
list.Add(new Todo() { Id = 3, Name = "Todo 3", Code = "T3" });
list.Add(new Todo() { Id = 4, Name = "Todo 4", Code = "T4" });
list.Add(new Todo() { Id = 5, Name = "Todo 5", Code = "T5" });
varlistDropDown = LSM.Generic.Mvc.MvcMapper.GetListOfSelectListItem<Todo>(list);
The Tidelift Subscription provides access to a continuously curated stream of human-researched and maintainer-verified data on open source packages and their licenses, releases, vulnerabilities, and development practices.