while updating a record I want o add where clause .I dont want to use the default primary keys as declared in entity . :?:
hi
how to get database generated identity after adding new records?Mine is always showing 0
thanks
hi
json result is wrapped inside "result" object .how I can change or rename that ex: original :- "result" : { name:"mike", } desired: "data":{[ name:"mike", ]} thanks
i can even see the insert statement in sqlprofiler but it is not written in database ,I wonder if it is rollbacked or how ?
The thread 0x291c has exited with code 259 (0x103). Opened connection asynchronously at 3/7/2016 8:57:21 PM +08:00
INSERT [dbo].[Sale_Mast]([TenantId], [Invdt], [Invduedt], [Currency], [Currate], [Custid], [Export], [Comments], [Invno], [Branchid], [IsDeleted], [DeleterUserId], [DeletionTime], [LastModificationTime], [LastModifierUserId], [CreationTime], [CreatorUserId], [Id]) VALUES (@0, @1, @2, @3, @4, @5, @6, @7, @8, NULL, @9, NULL, NULL, NULL, NULL, @10, @11, @12) SELECT [Sslno] FROM [dbo].[Sale_Mast] WHERE @@ROWCOUNT > 0 AND [Sslno] = scope_identity()
-- @0: '2' (Type = Int32)
-- @1: '3/7/2016 12:00:00 AM' (Type = DateTime2)
-- @2: '3/7/2016 12:00:00 AM' (Type = DateTime2)
-- @3: 'USD' (Type = String, Size = -1)
-- @4: '1' (Type = Decimal, Precision = 18, Scale = 2)
-- @5: 'harry' (Type = String, Size = -1)
-- @6: 'False' (Type = Boolean)
-- @7: 'lol' (Type = String, Size = -1)
-- @8: '100' (Type = String, Size = 50)
-- @9: 'False' (Type = Boolean)
-- @10: '3/7/2016 8:57:21 PM' (Type = DateTime2)
-- @11: '3' (Type = Int64)
-- @12: '0' (Type = Int32)
-- Executing asynchronously at 3/7/2016 8:57:21 PM +08:00
-- Completed in 3 ms with result: SqlDataReader
Closed connection at 3/7/2016 8:57:21 PM +08:00
The thread 0x4938 has exited with code 259 (0x103).
while creating new record error is coming .Reading record is working fine.mentioned below Error,Model entity ,Input entity
error : A first chance exception of type 'AutoMapper.AutoMapperMappingException' occurred in AutoMapper.dll
salemast class
public virtual int TenantId { get; set; }
[Table("Sale_Mast")]
public class Salemast : FullAuditedEntity, IMustHaveTenant
{
public virtual int TenantId { get; set; }
[Required]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
public virtual System.DateTime Invdt { get; set; }
[Required]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
public virtual System.DateTime Invduedt { get; set; }
[Required]
public virtual string Currency { get; set; }
[Required]
public virtual decimal Currate { get; set; }
[Required]
public virtual string Custid { get; set; }
[Required]
public virtual bool Export { get; set; }
[Required]
public virtual string Comments { get; set; }
[Required]
[StringLength(50)]
public virtual string Invno { get; set; }
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public virtual int Sslno { get; set; }
public virtual string Branchid { get; set; }
public virtual ICollection<Saledetails> Saledetails { get; set; }
}
[AutoMapFrom(typeof(Salemast))] public class CreateSaleInput : IInputDto {
[Required]
public System.DateTime Invdt { get; set; }
[Required]
public System.DateTime Invduedt { get; set; }
[Required]
public string Currency { get; set; }
[Required]
public decimal Currate { get; set; }
[Required]
public string Custid { get; set; }
public bool Export { get; set; }
public string Comments { get; set; }
[Required]
[StringLength(50)]
public string Invno { get; set; }
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Sslno { get; set; }
public string Branchid { get; set; }
}
hi
my salesdto contains one extra propert 'Amount' which is not present in sale model. Amount is the result of price*weight in child saledetails table
question is how and in which module I should fill up the amount property of saledto
Please be as elaborate as possible as I am not a seasonal programmer , my salerepository is mentioned below.
thanks :?:
public ListResultOutput<Salelistdto> GetSale(Getsaleinput input)
{
var sales = _saleRepository
.GetAll()
.Include(p => p.Saledetails.Select( c=> c.Price*c.Weight) )
.WhereIf(
!input.Filter.IsNullOrEmpty(),
p => p.Invno.Contains(input.Filter) ||
p.Invdt.Equals(input.Filter) ||
p.Custid.Contains(input.Filter)
)
.OrderBy(p => p.Invno)
.ThenBy(p => p.Invdt)
.ToList();
return new ListResultOutput<Salelistdto>(sales.MapTo<List<Salelistdto>>());
}