I've started using the FormView control to enable two way databinding in asp.net webforms. I liked that it saved me the trouble of writing loadForm and unloadForm routines on every page. So it seemed to work nicely at the start when I was just using textboxes everywhere....but when it came time to start converting some to DropDownLists...
Can Automapper map values from a NameValueCollection onto an object, where target.Foo receives the value stored in the collection under the "Foo" key?
I have a business object that stores some data in named properties and other data in a property bag. Different views make different assumptions about the data in the property bag, which ...
I am using ASP.NET MVC 2, and am using a view-model per view approach. I am also using Automapper to map properties from my domain-model to the view-model.
Take this example view-model (with Required data annotation attributes for validation purposes):
public class BlogPost_ViewModel
{
public int Id { get; set; }
[Required]
...
Mapper.CreateMap<BusinessObject, Proxy.DataContacts.DCObject>()
.ForMember(x => x.ExtensionData, y => y.Ignore())
.ForMember(z => z.ValidPlaces, a=> a.ResolveUsing(typeof(ValidPlaces)));
Mapper.AssertConfigurationIsValid();
proxydcObject = Mapper.Map<BusinessObject, Proxy.DataContracts.DCObject>(_instanceOfBusinessObject); //thro...
Is there a way to intercept the mapping of each property? What I would really like to do is something like ForAllMembers(opt => opt.Ignore(Func);
My ultimate goal is to implement column permission checking. But I want an opt in strategy such that all fail unless secured, and I do not want to have to touch my mapping configuration if...
I'm trying to map int IdPost on DTO to Post object on Blog object, based on a rule.
I would like to achieve this: BlogDTO.IdPost => Blog.Post
Post would be loaded by NHibernate: Session.Load(IdPost)
How can I achieve this with AutoMapper?
...
Any idea how I can tell AutoMapper to resolve a TypeConverter constructor argument using StructureMap?
ie. We have this:
private class StringIdToContentProviderConverter : TypeConverter<string, ContentProvider> {
private readonly IContentProviderRepository _repository;
public StringIdToContentProviderConverter(ICon...
I have an object like this:
public class Foo {
public string Title { get; set; }
public IList<FooChild> Children { get; set; }
}
public class FooChild {
public string Title { get; set; }
}
I want to map this onto a view model like this:
public class FooDTO {
public string Title { get; set; }
public List<string> C...
Currently we are running AutoMapper 1.0.1.156 in production on a WCF webservice and after about a week or so we will start to get the following error (note this was also happening in 0.4.0.126 but we couldn't get a stack trace because we only had the .dll from codeplex and no .pdb):
Trying to map DataAccess.Call to DataTypes.Call.
...
Here is my custom Type Converter.
public class StringListTypeConverter : TypeConverter<String, IEnumerable<String>>
{
protected override IEnumerable<string> ConvertCore(String source)
{
if (source == null)
yield break;
foreach (var item in source.Split(','))
yield return item.Trim();
...
I am building a MVVM application. The model / entity (I am using NHibernate) is already done, and I am thinking of using AutoMapper to map between the ViewModel and Model.
However this clause scares the jebus out of me: (from http://www.lostechies.com/blogs/jimmy_bogard/archive/2009/01/22/automapper-the-object-object-mapper.aspx)
Bl...
I have two classes as below.
public class Destination
{
public Destination()
{
_StringCollection = new List<String>();
}
private ICollection<String> _StringCollection;
public IEnumerable<String> StringCollection
{
get
{
return _StringCollection.AsEnumerable<String>();
}
}
public void ...
I am trying to map the ReferralContract.AssessmentId property to Referral.Assessment.Id
The below code works but I am sure that there is a cleaner way to do.... Please tell me this is so ;-)
// Destination classes
public class Referral
{
public Referral()
{
Assessment = new Assessment();
}
public int Id { get; ...
What do you think? How do you map between your domain and presentation model?
...
I have two classes like so:
public class SentEmailAttachment : ISentEmailAttachment
{
public SentEmailAttachment();
public string FileName { get; set; }
public string ID { get; set; }
public string SentEmailID { get; set; }
public string StorageService { get; set; }
public string StorageServiceFileID { get; set;...
I'm trying to build a way of mapping from one type to another, knwoing they will (should) have the same structure. Related Question.
For ease of the fiddly bits, I'm using AutoMapper from Codeplex, with the following function:
private static List<Type> seenTypes = new List<Type>();
private static void MapDataObjects(Type a, Type b)
{
...
Is there any way to auto-configue Automapper to scan for all profiles in namespace/assembly? What I would like to do is to add mapping profiles to AutoMapper from given assembly filtered by given interface, something like Scan Conventions in StructureMap:
public static void Configure()
{
ObjectFactory.Initialize(x =>
...
Is it possible to ignore depending on destination value?
look what i want to do:
object c;
var key = ce.CreateEntityKey<CustomerDataContract, Customer>("FullCustomerSet", item, o => o.ID);
if (ce.TryGetObjectByKey(key, out c))
{
Mapper.Map(item, (Customer)c);
}
else
{
c = Mapper.Map<CustomerDataContract...
Hello,
I have an AutoMapper issue that has been driving me crazy for way too long now. A similar question was also posted on the AutoMapper user site but has not gotten much love.
The summary is that I have a container class that holds a Dictionary of components. The components are a derived object of a common base class. I also have a...
I have two classes:
public class TestClass1
{
public int TestInt { get; set; }
public void TestMethod()
{
// Do something
}
}
public class TestClass2
{
public int TestInt { get; set; }
public void TestMethod()
{
// Do something
}
}
I want to create interface that I can use for both cl...