I'm using Fluent NHibernate
to help with ORM
(replacing .hbm files manually) with a single class:
User Class:
public class Usuario
{
public virtual int Id { get; set; }
public virtual string Nome { get; set; }
public virtual string Login { get; set; }
public virtual string Senha { get; set; }
public virtual char Status { get; set; }
}
Class Mapping:
public class UsuarioMap : ClassMap<Usuario>
{
public UsuarioMap()
{
Id(c => c.Id);
Map(c => c.Nome);
Map(c => c.Login);
Map(c => c.Senha);
Map(c => c.Status);
Table("usuarios");
}
}
Adding mapping to Fluent NHibernate
var configMap = Fluently.Configure().Database(configDB).Mappings(c => c.FluentMappings.AddFromAssemblyOf<Mapeamento.UsuarioMap>());
Question: Now I need to add another class (Address, the User instance will have an Address property) and a Vendor class (which is not bound to any other) what would this mapping look like?
New User Class:
public class Usuario
{
public virtual int Id { get; set; }
public virtual string Nome { get; set; }
public virtual string Login { get; set; }
public virtual string Senha { get; set; }
public virtual char Status { get; set; }
public virtual Endereco EnderecoResidencial { get; set; }
}
Address Class:
public class Endereco
{
public virtual string Rua { get; set; }
public virtual string Quadra { get; set; }
public virtual string Lote { get; set; }
public virtual string Bairro { get; set; }
public virtual string CEP { get; set; }
public virtual string Complemento { get; set; }
public virtual string PontoReferencia { get; set; }
}
Supplier Class:
public class Fornecedor
{
public virtual string CNPJ { get; set; }
public virtual string NomeFantasia { get; set; }
public virtual string RazaoSocial { get; set; }
public virtual string Descricao { get; set; }
}