Skip to content

Commit

Permalink
previous one again
Browse files Browse the repository at this point in the history
  • Loading branch information
jtraband committed Sep 26, 2012
1 parent ff0cf00 commit 69e8ee9
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Breeze.Client/Scripts/breeze.debug.js
Expand Up @@ -10243,7 +10243,7 @@ function (core, m_entityAspect, m_entityMetadata, m_entityManager, m_entityQuery
define('root',["core", "entityModel"],
function (core, entityModel) {
var root = {
version: "0.58",
version: "0.59",
core: core,
entityModel: entityModel
};
Expand Down
Binary file modified Breeze.WebApi/Breeze.WebApi.dll
Binary file not shown.
12 changes: 8 additions & 4 deletions Breeze.WebApi/EFContextProvider.cs
Expand Up @@ -5,6 +5,7 @@
using System.Data;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Data.EntityClient;
using System.Data.Metadata.Edm;
using System.Data.Objects;
using System.Globalization;
Expand All @@ -17,9 +18,6 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using System.Text;
using System.Web;
using System.Data.EntityClient;

namespace Breeze.WebApi {

Expand Down Expand Up @@ -119,6 +117,13 @@ public class EFContextProvider<T> where T : class, new() {
return new SaveResult() {Entities = entities, KeyMappings = keyMappings};
}

/// <summary>
/// The method is called for each entity to be saved before the save occurs. If this method returns 'false'
/// then the entity will be excluded from the save. There is no need to call the base implementation of this
/// method when overriding it.
/// </summary>
/// <param name="entityInfo"></param>
/// <returns></returns>
public virtual bool BeforeSaveEntity(EntityInfo entityInfo) {
return true;
}
Expand Down Expand Up @@ -176,7 +181,6 @@ public class EFContextProvider<T> where T : class, new() {
#region Save related methods

private List<EntityInfo> ProcessSaves(Dictionary<Type, List<EntityInfo>> saveMap) {
saveMap = BeforeSaveEntities(saveMap);
var deletedEntities = new List<EntityInfo>();
foreach (var kvp in saveMap) {
var entityType = kvp.Key;
Expand Down
Binary file modified BuildPutFtp.ps1
Binary file not shown.
2 changes: 1 addition & 1 deletion DocCode/BreezeDocCode/Scripts/lib/breeze.debug.js
Expand Up @@ -10243,7 +10243,7 @@ function (core, m_entityAspect, m_entityMetadata, m_entityManager, m_entityQuery
define('root',["core", "entityModel"],
function (core, entityModel) {
var root = {
version: "0.58",
version: "0.59",
core: core,
entityModel: entityModel
};
Expand Down
Binary file modified DocCode/BreezeDocCode/ThirdParty/Breeze.WebApi.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion Samples/Todo/Todo/Scripts/lib/breeze.debug.js
Expand Up @@ -10243,7 +10243,7 @@ function (core, m_entityAspect, m_entityMetadata, m_entityManager, m_entityQuery
define('root',["core", "entityModel"],
function (core, entityModel) {
var root = {
version: "0.58",
version: "0.59",
core: core,
entityModel: entityModel
};
Expand Down
Binary file modified Samples/Todo/Todo/ThirdParty/Breeze.WebApi.dll
Binary file not shown.
@@ -1,6 +1,7 @@
#define DBCONTEXT_PROVIDER
//
using System;
using System.Data;
using System.Linq;
using System.Web.Http;
using Breeze.WebApi;
Expand All @@ -27,7 +28,12 @@ public class NorthwindContextProvider: EFContextProvider<NorthwindIBContext_EDMX


public override bool BeforeSaveEntity(EntityInfo entityInfo) {
return true;
// prohibit any additions of entities of type 'Role'
if (entityInfo.Entity.GetType() == typeof(Role) && entityInfo.EntityState == EntityState.Added) {
return false;
} else {
return true;
}
}

public override Dictionary<Type, List<EntityInfo>> BeforeSaveEntities(Dictionary<Type, List<EntityInfo>> saveMap) {
Expand Down
1 change: 1 addition & 0 deletions testFile.txt
@@ -0,0 +1 @@
ASDaasdfasdfasd

0 comments on commit 69e8ee9

Please sign in to comment.