Note that there are some explanatory texts on larger screens.

plurals
  1. POMap only certain properties using Automapper
    primarykey
    data
    text
    <p>I'm trying to map model to entity object, but when I map entity object that received from DB - my changes doesn't save in database.</p> <p>Here is some code:</p> <p>Mapping configuration:</p> <pre class="lang-cs prettyprint-override"><code>Mapper.CreateMap&lt;WalletUpdateModel, Wallet&gt;() .ForMember(o =&gt; o.Name, m =&gt; m.MapFrom(d =&gt; d.Name)) .ForMember(o =&gt; o.Currency, m =&gt; m.MapFrom(d =&gt; d.Currency)); </code></pre> <p>Entity object:</p> <pre class="lang-cs prettyprint-override"><code>public partial class Wallet { public Wallet() { this.Transactions = new HashSet&lt;Transaction&gt;(); } public int Id { get; set; } public int Owner { get; set; } public string Name { get; set; } public string Currency { get; set; } public virtual ICollection&lt;Transaction&gt; Transactions { get; set; } } </code></pre> <p>Model declaration:</p> <pre class="lang-cs prettyprint-override"><code>public class WalletUpdateModel { [Required] [Range(1, int.MaxValue)] public int Id { get; set; } [Required] [MaxLength(128)] public string Name { get; set; } [Required] [MaxLength(3)] [DataType(DataType.Currency)] public string Currency { get; set; } } </code></pre> <p>And some debugging info from Immediate window:</p> <pre class="lang-cs prettyprint-override"><code>w (before mapping) {System.Data.Entity.DynamicProxies.Wallet_E3CA830BB5384920A3E07D4B44F15D2409093A34BFCED7CA33F9EC4102445554} [System.Data.Entity.DynamicProxies.Wallet_E3CA830BB5384920A3E07D4B44F15D2409093A34BFCED7CA33F9EC4102445554]: {System.Data.Entity.DynamicProxies.Wallet_E3CA830BB5384920A3E07D4B44F15D2409093A34BFCED7CA33F9EC4102445554} Currency: "PLN" Id: 2 Name: "Cash" Owner: 1 Transactions: Count = 0 w (after mapping) {Financica.WebServices.Wallet} Currency: "PLN" Id: 2 Name: "BZWBK" Owner: 0 Transactions: Count = 0 </code></pre> <p>Please, help me fix this problem, thank you.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload