internal static void DeleteNoSave(Guid key, ResourcesModelContainer model, Type resType)
        {
            var existing = model.Set(resType)
                           .Find(key);

            if (existing != null)
            {
                model.Set(resType).Remove(existing);
            }
        }
 protected override IEnumerable <T> QueryItems <T>(Expression <Func <T, bool> > predicate)
 {
     using (var model = new ResourcesModelContainer())
     {
         return(model.Set <T>().Where(predicate));
     }
 }
Beispiel #3
0
 protected override IEnumerable <KeyValuePair <Guid, T> > GetItemsTyped(IEnumerable <Guid> id)
 {
     using (var m = new ResourcesModelContainer())
     {
         return(m.Set <T>().OfType <BaseEntity>().Where(k => id.Contains(k.Id)).ToDictionary(k => k.Id, k => k as T));
     }
 }
Beispiel #4
0
 protected override T GetItemTyped(Guid id)
 {
     using (var m = new ResourcesModelContainer())
     {
         return(m.Set <T>().OfType <BaseEntity>().FirstOrDefault(k => k.Id == id) as T);
     }
 }
        internal static void WriteNotSave(Guid key, object resource, ResourcesModelContainer model, Type resType)
        {
            var existing = model.Set(resType)
                           .Find(key);

            if (existing == null)
            {
                (resource as BaseEntity).Id = key;
                model.Set(resType).Add(resource);
            }
            else
            {
                EmitMapper.ObjectMapperManager.DefaultInstance
                .GetMapperImpl(resType, resType, new DefaultMapConfig())
                .Map(resource, existing, new object());
            }
        }