What is the best way to run raw SQL against NHibernate, then push it into List using AutoMapper?
Example:
public virtual List<T> GetList<T>(string mainsql)
{
IQuery q = GetSession().CreateSQLQuery(mainsql);
IEnumerable srcAllRows = q.List();
List<T> targetAllRows = new List<T>();
*** do AutoMapper thing to get srcAllR...
As suggested in this answer http://stackoverflow.com/questions/2183401/using-profiles-in-automapper-to-map-the-same-types-with-different-logic, can anybody provide an example of using Automapper with different Configuration object?
I need to have two or more configuration for mapping between two objects. How can I register many configura...
I have the following Dto and entity with a nested sub entity.
public class Dto
{
public string Property { get; set; }
public string SubProperty { get; set; }
}
public class Entity
{
public string Property { get; set; }
public SubEntity Sub { get; set; }
}
public class SubEntity
{
public string SubProperty { get; se...
I'm using AutoMapper to map domain entities to view models in an Asp.Net MVC app. I register these mapping classes in Castle Windsor so they are available to the controller thru ctor dependency injection. These mapping classes has a virtual CreateMap method where I can override AutoMapper's mapping, telling it how to map fields from th...
I am getting an AutoMapper Exception when i try to Map my DomainModel to ViewModel,
Here is my Domain Model Class,
public class Source{
public string Name {get;set;}
..............
public CustomCollection EmpDetails {get;set;}
}
public class CustomCollection:CollectionBase,IEnumerable<ClassA> {
public CustomCollection{}
public i...
I have two entities: Employee and Team.
What I want is an EmployeeForm that has the Name of the Team.
How can I achieve this using AutoMapper?
My current "solution" is the following:
Mapper.CreateMap<Employee, EmployeeForm>()
.ForMember(dest => dest.TeamName, opt => opt.MapFrom(x => x.GetTeams().FirstO...
I'm using Mapper.DynamicMap() inside a generic method and would like to, without using .CreateMap(), ignore some any source values that are null. Is this even possible?
...
I would like to use Automapper to map my model objects to database objects. Let say database object is over 30 fields and I want map 10 out of 20 properties from my model. To make it more complex I need to map different properties when I update record than when I insert new record to database.
The solution I'm using is to create 2 gener...
I've updated my question as I realised that my code was the cause of the original issue. However in investigating the problem further I've now come across an exception that occurs in my code during the mapping process, but I am unable to capture in my mapping expression extension.
Basically the code below will throw a keynotfoundexcept...
I'm using Fluent NHibernate's automapper to map the following domain model (via AutoMap.AssemblyOf<Ticket>()), but it's throwing an exception when creating a SessionFactory.
class Ticket {
Owner TicketOwner { get; set; }
Owner CreatedBy { get; set; }
}
abstract class Owner {
ICollection<Ticket> OwnedTickets { get; set; }
...
I have an entity called Incident and a DTO called IncidentDTO. For now, IncidentDTO simply looks like this:
public class IncidentDTO : Incident
{
// empty until I can get AutoMapper working correctly
}
I'm trying to pull a list of all the Incidents in the database and convert them to DTOs using this code:
Mapper.CreateMap<Inciden...
Hi All,
I've found a couple of posts that describe similar scenarios to mine but nothing that has the same concept or has been resolved so I'm sure I will get complaints about this question but I still want to ask it so some of you more knowledgeable than my self can give me some advice.
My problem is hydrating a Viewmodel from a Lin...
I have a Student object:
public class Student
{
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
}
And a Classroom object:
public class Classroom
{
public List<Student> Students { get; set; }
}
I want to use AutoMapper to convert the list of students to a list o...
Let's say I have the following entity:
public class Store
{
public List<Product> Products { get; set; }
public List<Employee> Employees { get; set; }
public List<Camera> Cameras { get; set; }
}
In other words, a Store that has Products, Employees, and security Cameras. I want to convert this Store to a StoreDTO:
public cl...
I am trying to create a custom resolver for automapper which needs to access one of my data repositories to retreive the logged in users account.
Here is my code so far...
public class FollowingResolver : ValueResolver<Audio, bool>
{
readonly IIdentityTasks identityTasks;
public FollowingResolver(IIdentityTasks ide...
Hi eveybody,
I'm designing a C# application
Presentation ( web site + flex apps )
Business Logical Layer (might be WCF to enable multi client platforms)
Data Access Layer ( With NHibernate )
We're going to integrate our solution in many preexistant client's database environnements and we would like to use NHibernate in the DAL.. My...
What is the best way to create a bootstrapper for my MVC 2 app? I'm using Unity and AutoMapper and want to abstract the loading and configuration of them as much as possible.
A decent example is here (http://weblogs.asp.net/rashid/archive/2009/02/17/use-bootstrapper-in-your-asp-net-mvc-application-and-reduce-code-smell.aspx
), but Unit...
I am using Automapper to convert between my EF4 Models and my ViewModels. Automapper needs map relationships declared and I find myself copy/pasting them inside every controller's constructor.
Mapper.CreateMap<CoolObject, CoolObjectViewModel>();
Where can I place the mapping declarations so they will only be called once and not every ...
In the project I'm working on, we are mapping auto-generated DTOs to business objects. The database has an ahem unusual (but largely consistent) naming convention, which means that it's possible to transform most DTO property names to their equivalent business object property names, thus saving many lines of code.
For example, in the D...
Consider the following scenario. I have a number of classes that share a common base class and I have defined an automapper mapping for each derived class. Something like this:
class A : Base {}
class B : Base {}
class ContractA : ContractBase {}
class ContractB : ContractBase {}
void Foo()
{
Mapper.CreateMap<A, ContractA>();
...