public class Category
{
public int Id { get; set; }
public string Name { get; set; }
public string Definition { get; set; }
public int ParentId { get; set; }
}
public class Brand
{
public int Id { get; set; }
public string Name { get; set; }
public string Definition { get; set; }
}
{
public int Id { get; set; }
// public int UnitId { get; set; }
public Unit Unit { get; set; }
// public int CategoryId { get; set; }
public Category Category { get; set; }
// public int BrandId { get; set; }
public Brand Brand { get; set; }
public string Name { get; set; }
public string Definition { get; set; }
}
Sql Query;
Select p.Id, p.Name, p.Definition,
p.UnitId, u.Name, u.Definition,
p.CategoryId, c.Name, c.Definition,
p.BrandId, b.Name, b.Definition
FROM Products p
LEFT join Units u ON p.UnitId = u.Id
LEFT JOIN Categories c ON c.Id = p.CategoryId
LEFT JOIN Brands b ON b.Id = p.BrandId
public class TypePrefixConvention:Convention
{
public TypePrefixConvention()
{
My Entities ;
public class Category { public int Id { get; set; } public string Name { get; set; } public string Definition { get; set; } public int ParentId { get; set; }
} public class Brand { public int Id { get; set; } public string Name { get; set; } public string Definition { get; set; } }
{ public int Id { get; set; } // public int UnitId { get; set; } public Unit Unit { get; set; } // public int CategoryId { get; set; } public Category Category { get; set; } // public int BrandId { get; set; } public Brand Brand { get; set; } public string Name { get; set; } public string Definition { get; set; } }
Sql Query;
Select p.Id, p.Name, p.Definition, p.UnitId, u.Name, u.Definition, p.CategoryId, c.Name, c.Definition, p.BrandId, b.Name, b.Definition FROM Products p LEFT join Units u ON p.UnitId = u.Id LEFT JOIN Categories c ON c.Id = p.CategoryId LEFT JOIN Brands b ON b.Id = p.BrandId
public class TypePrefixConvention:Convention { public TypePrefixConvention() {
} I want it to match the Id for both categoryId and BrandId.
example: FluentMapper.Initialize(config=>config.AddConvention().ForEntity().ForEntity())
Only the first entity matches for Id.