.net - Whats Automapper For
Jan 19, 2010What's Automapper for? How will it help me with my domain and controller layer (asp.net mvc)
View 3 RepliesWhat's Automapper for? How will it help me with my domain and controller layer (asp.net mvc)
View 3 RepliesI work on our intranet, which is continuously being updated with new features or fixed bugs. Bugs and features are added to JIRA and then assigned to myself so that I can take care of those. Now I would like to add a new feature to the intranet, which shows the following information:
Current SVN version.
Current list of bug/fixes changes
What is the best way to achive both without hard-coding it into the website?
I am using ASP.NET.
I hope I explained everything.
Update 1:
I found the following link to solve #2: http://www.fatlemon.co.uk/2008/12/automatic-svn-revision-numbering-in-asp-net-mvc/
This may be a little more up the alley of our mvc fellows, but regardless.
First, I have the following model:
Csharp Code:
[code]....
Notes: RenderPartials is a custom extension method and that part works, as do the actual views. The correct data is displayed. Just not in the expected order. In fact, it mirrors the database.
Can it handle mapping using private members like NHibernate can? The documentation is very slim, but it seems like one of the objects or methods provided with the tool could do something like this.
Mapper
.With<FooDTO>()
.Map(x => x.Value)
.To<Foo>("_value");
// To<T>(string member) or To<T>(Func<T, bool> func)
Mapper.CreateMap<Foo, FooDTO>();
I know my example methods don't exist as-is, but maybe I've overlooked something else already built in.
Whats are the major disadvantages of using Membership API? And when should i consider relying on using manual coding?
View 1 Replies<globalization
requestEncoding="utf-8"
responseEncoding="utf-8"
culture="en-US"
/>
Whats better utf-8 or iso-8859-1 And why does it matter? I have used iso-8859-1 as I understand it stricker on HTML markup is it not? Which is better for html accurate markup ?
I'm trying to figure out the best approach to architecting this project. Basically, it's a "band" profile site. I'm using ASP.NET 4, EF, and Automapper (structuremap too, but that's not important). I'm running into performance issues I have a EntityFramework repository class that interacts directly onto the EF objects using LINQ:
[Pluggable("Repository")]
public class EntityDataRepository : IRepository
static EntityDataRepository()
// other mappings removed
// Data. objects are EF objects, mapping to my DTO classes
[code]...
Is it possible with automapper in C# to map the properties of an object to an array/dictionary? I have tried the following:
Mapper.CreateMap<FFCLeads.Models.FFCLead, Dictionary<string, SqlParameter>>()
.ForMember(d => d["LeadID"], o => o.MapFrom(s => new SqlParameter("LeadID", s.LeadID)))
.ForMember(d => d["LastName"], o => o.MapFrom(s => new SqlParameter("LastName", s.LastName)));
However, it does not work (object ref not set to an instance). Basically, I'm trying to make the values of this object to an array of SqlParameter objects. Possible? If so, what is the correct way to do this?
am new to http handler concept and havent worked on it.What is http handlers and what is use of it??
View 1 RepliesI am running VS2010 with the latest AJAX toolkit installed.I dont know when I use Ajax controls if I am supposed to drop a ScriptManager or a ToolkitScriptManager on my .aspx page.
View 1 RepliesCurrently im using EF and using its datacontext directly in all of my actions, but since i started reading about loose coupling and testability im thinking that thats not the best way to go. Im trying to understand all the pro's and con's before i start refactor all my current code.
Problem 1:
Considering that every entity needs its own repository, and thus has to setup its own connection to a datasource (lets assume a database using EF), wouldnt that give alot of overhead if i need data from 5 different entities on a single page?
Problem 2:
What im seeing aswell in all the examples which i found online is that most people (even people like shanselman) implement the repository pattern using the entity classes which are generated by either LINQ or EF, doesn't this defeat the purpose of repository pattern with regards to loose coupling? On the other hand, what is the alternative, using POCO classes in combination with for example AutoMapper? (this scares me a little) Im hoping that a few people can shed some light on this, because im a bit confused at the moment if the repository pattern is the right choice for a website.
I was wondering if it is possible to map multiple DTO objects to a single ViewModel object using Automapper?
Essentially, I have multiple DTO objects and would like to display information from each on a single screen in ASP.NET MVC 2.0. To do so I would like to flatten the DTO objects (or parts of them...) into the Viewmodel and pass said viewmodel to the view. If I had one DTO this would be easy, but I've never seen it being done with multiple. Obviously there are a number of roundabout ways to do this (outside of automapper), but this is the approach that I would like to take if possible.
im currently working with php but everyone is telling me that asp.net is so much better and i was just wondering what the real story is
View 2 RepliesI'm completely new to AutoMapper, and I have a View that looks like this:
@using (Html.BeginForm(null, null, FormMethod.Post, new { enctype = "multipart/form-data" }))
{
@Html.ValidationSummary(true)
<fieldset>
<legend>Consultant</legend> [code]...
This is pretty much the same error I got when trying to use the entity object directly as model, rather than having AutoMapper create a ViewModel. So what am I doing wrong? This is driving me crazy...
UPDATE 3:Well, neverending story... I found some info on using UseDestinationValue on the CreateMap method in AutoMapper. So I tried that, and well, that actually got me a bit further. But...now I get a new exception on SaveChanges() (in the EF model). The exception now is: "The operation failed: The relationship could not be changed because one or more of the foreign-key properties is non-nullable." This appears to be an exception that also occurs when trying to delete child objects in a one-to-many relationship if you don't have cascade delete set, but that's not what I'm trying to do here...
Here's the updated CreateMap methods:Mapper.CreateMap<ConsultantViewModel, Consultant>().ForMember("Id", opts => opts.Ignore()).ForMember(
x => x.Programs, opts => opts.UseDestinationValue());
Mapper.CreateMap<Consultant, ConsultantViewModel>();
I want to assign Guid to UserId of my UserDTO if UserId is Null. Is it possible to do this in the CreateMap or creating any formatter?. I am using automapper as an attribute on my Actions in controller.
protected override void Configure()
{
Mapper.CreateMap<User, UserDTO>()
.ForMember(d => d.FullName, o => o.MapFrom(s => s.FirstName + " " + s.LastName));
}
I am using AUtomapper which I am very impressed with however, I have a complex object with many nested collections. I'm using Telerik OpenAccess and it returns the 1400 records fast but when I pass it to Automapper and it slows to a ridiculous crawl. Here is my code for reference:
List<DAL.Event> query = httpContext.Events.Where(e => e.Inactive != true && e.Event_Locations != null).ToList();
Mapper.CreateMap<DAL.Event, EventDTO>();
Mapper.CreateMap<DAL.Event_Association, EventAssociationDTO>(); [code]....
I have following doimain objects:
public class ComponentType
{
public int ComponentTypeID { get; set; }
public string Component_Type { get; set; }
public string ComponentDesc { get; set; }
}
[code]...
I have a feeling that Request.ServerVariables("AUTH_USER") and User.Identity.Name return the same string while using FormsAuthentication.So my question is as simple as that. Which one should i better use?
View 1 RepliesWhats the difference between Html.Partial and Html.RenderPartial?
[Code]....
where should we use clustered index and non clustered index.i mean in day to day use which on e to choice and how to make decision.
View 8 Replies