示例#1
0
        public static T EnsureEntity <T, TKey>(this CrudBase <T, TKey> crud, string id, Action <T> update)
            where T : DbObject
        {
            var guid   = new Guid(id);
            var entity = crud.All().FirstOrDefault(e => e.Guid == guid);

            if (entity == null)
            {
                entity      = Activator.CreateInstance <T>();
                entity.Guid = guid;
                crud.Add(entity);
            }
            update(entity);
            return(entity);
        }
示例#2
0
 public virtual async Task <IQueryable <T> > Get()
 {
     return(Crud.All());
 }