Skip to content

Commit

Permalink
breeze.net - starting inheritance
Browse files Browse the repository at this point in the history
  • Loading branch information
jtraband committed Mar 14, 2014
1 parent c2bda0c commit 5d8f590
Show file tree
Hide file tree
Showing 9 changed files with 509 additions and 8 deletions.
1 change: 0 additions & 1 deletion Breeze.NetClient/_TODO.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
- implement JsonResultsAdapter


- Test fk hookup after a RejectChanges on a entity with changed fk.
20 changes: 13 additions & 7 deletions Breeze.NetClient/__Notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,23 @@

- EntityAspect EntityManager & EntityGroup properties are set if an entity was ever attached.
This is not cleared when an entity is detached. This assumption removes a lot of special purpose logic

- MetadataStore.Instance is a singleton - This is different than breeze.net because
1) We want to allow entities and complexObjects be created and manipulated before they are attached to an EntityManager. Once
we allow this we need somewhere for these new objects to get the metadata they need. For example, simply getting or setting a property
on an entity makes up of the properties DataProperty.
2) Each clrType can only have a single representation per the .NET runtime. We need to associate each
clrType with a single EntityType or ComplexType. Do we really want two instances of the a clrType
to have different EntityTypes. If we allowed a different version of the EntityType/Complex
type per EntityManager then we wouldn't have any easy way of working with detached entities
1) We want to allow entities and complexObjects be created and manipulated before they are attached to an EntityManager. Once
we allow this we need somewhere for these new objects to get the metadata they need. For example, simply getting or setting a property
on an entity makes use of the metadatastore properties.
2) Each clrType can only have a single representation per the .NET runtime. We need to associate each
clrType with a single EntityType or ComplexType. Do we really want two instances of the a clrType
to have different EntityTypes. If we allowed a different version of the EntityType/Complex
type per EntityManager then we wouldn't have any easy way of working with detached entities

- Only the MetadataStore and immutable types are ThreadSafe. Any property returned by the MetadataStore
must therefore also be either immutable or thread safe itself. (all StructuralTypes are effectively immutable)

- Unit tests are problematic because they do not run with a UI synchronization context which means that async calls within a test can return on
a different thread then they started on. Howver, most unit tests run safely despite this because they don't tend to run multiple threads simulataneously.
An exception to this is any call to Task.WhenAll or Task.WaitAll, use of these methods will require the test code to be wrapped in a UI synch context.

Think about
-------------
Abiltity to configure clr namespace mapping - server name: Foo.Customer - client name: Bar.Cust
Expand Down
17 changes: 17 additions & 0 deletions Breeze.net.sln
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample_WPF.EF6", "Sample_WP
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Model_Northwind_NetClient", "_Internal\Model_Northwind_NetClient\Model_Northwind_NetClient.csproj", "{AFBEDE2C-1937-4A3A-88A1-046973D969E5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Model_Inheritance_NetClient", "_Internal\Model_Inheritance_NetClient\Model_Inheritance_NetClient.csproj", "{5B809BB6-85EF-4384-BA2B-54889617F76F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -96,6 +98,21 @@ Global
{AFBEDE2C-1937-4A3A-88A1-046973D969E5}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{AFBEDE2C-1937-4A3A-88A1-046973D969E5}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{AFBEDE2C-1937-4A3A-88A1-046973D969E5}.Release|x86.ActiveCfg = Release|Any CPU
{5B809BB6-85EF-4384-BA2B-54889617F76F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5B809BB6-85EF-4384-BA2B-54889617F76F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5B809BB6-85EF-4384-BA2B-54889617F76F}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{5B809BB6-85EF-4384-BA2B-54889617F76F}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{5B809BB6-85EF-4384-BA2B-54889617F76F}.Debug|x86.ActiveCfg = Debug|Any CPU
{5B809BB6-85EF-4384-BA2B-54889617F76F}.Debug-ODATA|Any CPU.ActiveCfg = Debug|Any CPU
{5B809BB6-85EF-4384-BA2B-54889617F76F}.Debug-ODATA|Any CPU.Build.0 = Debug|Any CPU
{5B809BB6-85EF-4384-BA2B-54889617F76F}.Debug-ODATA|Mixed Platforms.ActiveCfg = Debug|Any CPU
{5B809BB6-85EF-4384-BA2B-54889617F76F}.Debug-ODATA|Mixed Platforms.Build.0 = Debug|Any CPU
{5B809BB6-85EF-4384-BA2B-54889617F76F}.Debug-ODATA|x86.ActiveCfg = Debug|Any CPU
{5B809BB6-85EF-4384-BA2B-54889617F76F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5B809BB6-85EF-4384-BA2B-54889617F76F}.Release|Any CPU.Build.0 = Release|Any CPU
{5B809BB6-85EF-4384-BA2B-54889617F76F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{5B809BB6-85EF-4384-BA2B-54889617F76F}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{5B809BB6-85EF-4384-BA2B-54889617F76F}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Binary file modified Samples/DocCode/DocCode/App_Data/NorthwindIB.sdf
Binary file not shown.
1 change: 1 addition & 0 deletions Test_NetClient/Breeze.NetClient.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
</Otherwise>
</Choose>
<ItemGroup>
<Compile Include="InheritanceTests.cs" />
<Compile Include="ValidationTests.cs" />
<Compile Include="EntityManagerTests.cs" />
<Compile Include="LocalQueryTests.cs" />
Expand Down
55 changes: 55 additions & 0 deletions Test_NetClient/InheritanceTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Threading.Tasks;
using System.Linq;
using Breeze.Core;
using Breeze.NetClient;
using System.Collections.Generic;
using Foo;

namespace Test_NetClient {

[TestClass]
public class InheritanceTests {

private Task<EntityManager> _emTask = null;
private EntityManager _em1;


[TestInitialize]
public void TestInitializeMethod() {
_emTask = SetUpAsync();
}

public async Task<EntityManager> SetUpAsync() {
var serviceName = "http://localhost:7150/breeze/Inheritance/";

if (MetadataStore.Instance.EntityTypes.Count == 0) {
_em1 = new EntityManager(serviceName);
await _em1.FetchMetadata();
} else {
_em1 = new EntityManager(serviceName);
}
return _em1;

}

[TestCleanup]
public void TearDown() {

}

[TestMethod]
public async Task SimpleQuery() {
await _emTask;
var q = new EntityQuery<Customer>();


}



}
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{5B809BB6-85EF-4384-BA2B-54889617F76F}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Model_Inheritance_NetClient</RootNamespace>
<AssemblyName>Model_Inheritance_NetClient</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Models.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Breeze.NetClient\Breeze.NetClient.csproj">
<Project>{54b1ce10-2847-4565-839a-26da3a51af38}</Project>
<Name>Breeze.NetClient</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
Loading

0 comments on commit 5d8f590

Please sign in to comment.