public virtual ActionResult AddEdit(string id) { int nId = 0; int.TryParse(id, out nId); var item = model.Find(nId); return(View(item)); }
//private static TDestination GetMapping<TSource, TDestination, TDbSet>(TSource source, System.Data.Entity.DbSet<TDbSet> destDbSet) where TDestination : MappableEntity, new() where TSource : MappableDTO where TDbSet : MappableEntity //{ // TDestination dest = null; // if (source?.MappingId != null) // { // dest = destDbSet.Find(source.MappingId) as TDestination; // } // if (dest == null) // { // dest = new TDestination(); // } // return dest; //} private static TDestination GetMapping <TSource, TDestination>(TSource source, TDestination dest, System.Data.Entity.DbSet <TDestination> destDbSet) where TDestination : MappableEntity where TSource : IMappableDTO { if (dest == null || source.MappingId != dest.MappingId) { if (source?.MappingId != null) { dest = destDbSet.Find(source.MappingId); return(dest); } else { return(null); } } return(dest); }
private static TDestination GetMapping <TSource, TDestination>(TSource source, System.Data.Entity.DbSet <TDestination> destDbSet) where TDestination : MappableEntity, new() where TSource : IMappableDTO { //return GetMapping<TSource, TDestination, TDestination>(source, destDbSet); TDestination dest = null; if (source?.MappingId != null) { dest = destDbSet.Find(source.MappingId); } if (dest == null) { dest = new TDestination(); } return(dest); }
public T Find(string Id) { return(dbSet.Find(Id)); }
/// <summary> /// Returns the object with the primary key specifies or throws /// </summary> /// <typeparam name="TU">The type to map the result to</typeparam> /// <param name="primaryKey">The primary key</param> /// <returns>The result mapped to the specified type</returns> public T Single(object primaryKey) { var dbResult = dbSet.Find(primaryKey); return(dbResult); }
public TEntity ObterPorId(int id) { return(_context.Find(id)); }