Browse Source

Added error page to EDM Wizard which displays edmgen.exe error messages, changed several outdated XML namespaces used by edmgen.exe to new EF 4.0 namespaces, added view support to EDM Wizard

pull/1/head
philippmaihart 15 years ago
parent
commit
45deb3a17b
  1. 4
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.Addin/Templates/Files/CSharp.EDMX.xft
  2. 1
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.Core.UI/ICSharpCode.Data.Core.UI.csproj
  3. 41
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.Core.UI/UserControls/WizardErrorUserControl.cs
  4. 26
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.Core.UI/UserControls/WizardUserControl.cs
  5. 73
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.Core.UI/Windows/WizardWindowInnards.xaml.cs
  6. 8
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.Core/DatabaseObjects/Column.cs
  7. 21
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.Core/DatabaseObjects/DatabaseObjectsCollection.cs
  8. 16
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.Core/DatabaseObjects/View.cs
  9. 6
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.Core/Interfaces/IView.cs
  10. 1
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.DemoApp/ICSharpCode.Data.DemoApp.csproj
  11. 37
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core/EDMObjects/SSDL/EntityType/EntityType.cs
  12. 8
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core/ICSharpCode.Data.EDMDesigner.Core.csproj
  13. 6
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core/IO/CSDLIO.cs
  14. 20
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core/IO/EDMXIO.cs
  15. 13
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core/IO/IO.cs
  16. 13
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core/IO/SSDLIO.cs
  17. 23
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core/ObjectModelConverters/EDMConverter.cs
  18. 39
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core/ObjectModelConverters/ObjectModelConverterException.cs
  19. 9
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core/ObjectModelConverters/SSDLConverter.cs
  20. 7
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core/Windows/EDMWizard/ChooseDatabaseObjectsUserControl.xaml.cs
  21. 14
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core/Windows/EDMWizard/EDMWizardErrorUserControl.xaml
  22. 44
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core/Windows/EDMWizard/EDMWizardErrorUserControl.xaml.cs
  23. 23
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core/Windows/EDMWizard/EDMWizardWindow.cs
  24. 28
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.SQLServer/SQLServerDatabaseDriver.cs

4
src/AddIns/DisplayBindings/Data/ICSharpCode.Data.Addin/Templates/Files/CSharp.EDMX.xft

@ -20,10 +20,9 @@ @@ -20,10 +20,9 @@
${Path} -> Full path of the file
-->
<Files>
<!--<File name="${FileNameWithoutExtension}.Designer.cs" language="C#" DependentUpon="${FileName}" SubType="Code"><![CDATA[${StandardHeader.C#}]]></File>-->
<File name="${FullName}" language="XML" buildAction="Page">
<![CDATA[<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx">
<edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2008/10/edmx">
<!-- EF Runtime content -->
<edmx:Runtime>
<!-- SSDL content -->
@ -36,6 +35,7 @@ @@ -36,6 +35,7 @@
<DesignerViews />
</edmx:Edmx>]]>
</File>
<File name="${FileNameWithoutExtension}.Designer.cs" language="C#" DependentUpon="${FileName}" SubType="Code"><![CDATA[${StandardHeader.C#}]]></File>
</Files>
<AdditionalOptions/>

1
src/AddIns/DisplayBindings/Data/ICSharpCode.Data.Core.UI/ICSharpCode.Data.Core.UI.csproj

@ -161,6 +161,7 @@ @@ -161,6 +161,7 @@
<Compile Include="UserControls\LoadingCircle.xaml.cs">
<DependentUpon>LoadingCircle.xaml</DependentUpon>
</Compile>
<Compile Include="UserControls\WizardErrorUserControl.cs" />
<Compile Include="UserControls\WizardUserControl.cs" />
<Compile Include="Windows\ConnectionWizardWindow.xaml.cs">
<DependentUpon>ConnectionWizardWindow.xaml</DependentUpon>

41
src/AddIns/DisplayBindings/Data/ICSharpCode.Data.Core.UI/UserControls/WizardErrorUserControl.cs

@ -0,0 +1,41 @@ @@ -0,0 +1,41 @@
#region Usings
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
#endregion
namespace ICSharpCode.Data.Core.UI.UserControls
{
public class WizardErrorUserControl : WizardUserControl
{
#region Fields
private Exception _exception = null;
#endregion
#region Properties
public override sealed bool CanFinish
{
get { return false; }
}
public Exception Exception
{
get { return _exception; }
set
{
_exception = value;
OnPropertyChanged("Exception");
}
}
public int PreviousIndex { get; set; }
#endregion
}
}

26
src/AddIns/DisplayBindings/Data/ICSharpCode.Data.Core.UI/UserControls/WizardUserControl.cs

@ -1,4 +1,7 @@ @@ -1,4 +1,7 @@
#region Usings
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
#region Usings
using System;
using System.Collections.Generic;
@ -59,6 +62,14 @@ namespace ICSharpCode.Data.Core.UI.UserControls @@ -59,6 +62,14 @@ namespace ICSharpCode.Data.Core.UI.UserControls
get { throw new NotImplementedException(); }
}
/// <summary>
/// Returns if this WizardUserControl is dependent of its predecessor user control.
/// </summary>
public virtual bool IsDependentOnPredecessor
{
get { return true; }
}
/// <summary>
/// Returns if this WizardUserControl can finish the WizardWindow.
/// </summary>
@ -108,6 +119,19 @@ namespace ICSharpCode.Data.Core.UI.UserControls @@ -108,6 +119,19 @@ namespace ICSharpCode.Data.Core.UI.UserControls
#region Methods
internal void Activate(bool activatedFromPredecessor)
{
if (activatedFromPredecessor && IsDependentOnPredecessor)
{
OnActivateFromPredecessor();
}
OnActivate();
}
public virtual void OnActivateFromPredecessor()
{ }
public virtual void OnActivate()
{ }

73
src/AddIns/DisplayBindings/Data/ICSharpCode.Data.Core.UI/Windows/WizardWindowInnards.xaml.cs

@ -1,4 +1,7 @@ @@ -1,4 +1,7 @@
#region Usings
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
#region Usings
using System;
using System.Collections.Generic;
@ -32,8 +35,10 @@ namespace ICSharpCode.Data.Core.UI.Windows @@ -32,8 +35,10 @@ namespace ICSharpCode.Data.Core.UI.Windows
DependencyProperty.Register("IsReadyForNextStep", typeof(bool), typeof(WizardWindowInnards), new FrameworkPropertyMetadata(false, IsReadyForNextStep_Changed));
private WizardWindow _wizardWindow = null;
private ObservableCollection<WizardUserControl> _wizardUserControls = new ObservableCollection<WizardUserControl>();
private WizardErrorUserControl _wizardErrorUserControl = null;
private WizardUserControl _currentWizardUserControl = null;
private int _currentIndex = 0;
private int _previousIndex = 0;
#endregion
@ -47,6 +52,15 @@ namespace ICSharpCode.Data.Core.UI.Windows @@ -47,6 +52,15 @@ namespace ICSharpCode.Data.Core.UI.Windows
get { return _wizardUserControls; }
}
/// <summary>
/// Gets or sets the current WizardWindows' user control for displaying errors.
/// </summary>
public WizardErrorUserControl WizardErrorUserControl
{
get { return _wizardErrorUserControl; }
set { _wizardErrorUserControl = value; }
}
/// <summary>
/// Returns the current WizardUserControls index of the WizardWindow.
/// </summary>
@ -55,6 +69,7 @@ namespace ICSharpCode.Data.Core.UI.Windows @@ -55,6 +69,7 @@ namespace ICSharpCode.Data.Core.UI.Windows
get { return _currentIndex; }
protected set
{
_previousIndex = _currentIndex;
_currentIndex = value;
_currentWizardUserControl = null;
OnPropertyChanged("CurrentIndex");
@ -73,10 +88,28 @@ namespace ICSharpCode.Data.Core.UI.Windows @@ -73,10 +88,28 @@ namespace ICSharpCode.Data.Core.UI.Windows
return _currentWizardUserControl;
else
{
_currentWizardUserControl = _wizardUserControls.FirstOrDefault(wuc => wuc.Index == _currentIndex);
BindingBase binding = new Binding("IsReadyForNextStep") { Source = _currentWizardUserControl };
SetBinding(WizardWindowInnards.IsReadyForNextStepProperty, binding);
ToggleEnabledButtons();
if (_currentIndex == -1)
{
_currentWizardUserControl = _wizardErrorUserControl;
}
else
{
_currentWizardUserControl = _wizardUserControls.FirstOrDefault(wuc => wuc.Index == _currentIndex);
BindingBase binding = new Binding("IsReadyForNextStep") { Source = _currentWizardUserControl };
SetBinding(WizardWindowInnards.IsReadyForNextStepProperty, binding);
}
if (_currentWizardUserControl != null)
{
if (_currentIndex != -1 && _currentIndex - 1 == _previousIndex)
_currentWizardUserControl.Activate(true);
else
_currentWizardUserControl.Activate(false);
ToggleEnabledButtons();
}
return _currentWizardUserControl;
}
}
@ -106,7 +139,7 @@ namespace ICSharpCode.Data.Core.UI.Windows @@ -106,7 +139,7 @@ namespace ICSharpCode.Data.Core.UI.Windows
if (!IsInitialized)
return;
if (CurrentIndex == 0)
if (_currentIndex == 0)
{
btnPrevious.IsEnabled = false;
}
@ -115,7 +148,7 @@ namespace ICSharpCode.Data.Core.UI.Windows @@ -115,7 +148,7 @@ namespace ICSharpCode.Data.Core.UI.Windows
btnPrevious.IsEnabled = true;
}
if (CurrentIndex == _wizardUserControls.Count - 1)
if (_currentIndex == -1 || _currentIndex == _wizardUserControls.Count - 1)
{
btnNext.IsEnabled = false;
}
@ -134,8 +167,6 @@ namespace ICSharpCode.Data.Core.UI.Windows @@ -134,8 +167,6 @@ namespace ICSharpCode.Data.Core.UI.Windows
}
else
btnFinish.IsEnabled = false;
CurrentWizardUserControl.OnActivate();
}
#endregion
@ -157,6 +188,10 @@ namespace ICSharpCode.Data.Core.UI.Windows @@ -157,6 +188,10 @@ namespace ICSharpCode.Data.Core.UI.Windows
{
if (CurrentIndex == 0)
return;
else if (CurrentIndex == -1)
{
CurrentIndex = _wizardErrorUserControl.PreviousIndex;
}
else
{
CurrentIndex--;
@ -175,7 +210,25 @@ namespace ICSharpCode.Data.Core.UI.Windows @@ -175,7 +210,25 @@ namespace ICSharpCode.Data.Core.UI.Windows
private void btnFinish_Click(object sender, RoutedEventArgs e)
{
_wizardWindow.OnFinished();
try
{
_wizardWindow.OnFinished();
}
catch (Exception ex)
{
if (_wizardErrorUserControl != null)
{
_wizardErrorUserControl.Exception = ex;
_wizardErrorUserControl.PreviousIndex = _currentIndex;
CurrentIndex = -1;
return;
}
else
{
throw ex;
}
}
_wizardWindow.DialogResult = true;
_wizardWindow.Close();

8
src/AddIns/DisplayBindings/Data/ICSharpCode.Data.Core/DatabaseObjects/Column.cs

@ -1,4 +1,7 @@ @@ -1,4 +1,7 @@
#region Usings
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
#region Usings
using System;
using System.Collections.Generic;
@ -191,6 +194,9 @@ namespace ICSharpCode.Data.Core.DatabaseObjects @@ -191,6 +194,9 @@ namespace ICSharpCode.Data.Core.DatabaseObjects
{
get
{
if (_parentTable.Constraints == null)
return false;
IConstraint constraint = _parentTable.Constraints.FirstOrDefault(constr => constr.FKColumns.FirstOrDefault(column => column.ColumnId == ColumnId && column.Name == Name) != null);
if (constraint == null)

21
src/AddIns/DisplayBindings/Data/ICSharpCode.Data.Core/DatabaseObjects/DatabaseObjectsCollection.cs

@ -1,4 +1,7 @@ @@ -1,4 +1,7 @@
#region Usings
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
#region Usings
using System;
using System.Collections.Generic;
@ -31,6 +34,22 @@ namespace ICSharpCode.Data.Core.DatabaseObjects @@ -31,6 +34,22 @@ namespace ICSharpCode.Data.Core.DatabaseObjects
}
}
public int SelectedItemsCount
{
get
{
int selectedItemsCount = 0;
foreach (T item in this)
{
if (item.IsSelected)
selectedItemsCount++;
}
return selectedItemsCount;
}
}
#endregion
#region Methods

16
src/AddIns/DisplayBindings/Data/ICSharpCode.Data.Core/DatabaseObjects/View.cs

@ -1,4 +1,7 @@ @@ -1,4 +1,7 @@
#region Usings
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
#region Usings
using System;
using System.Collections.Generic;
@ -14,12 +17,23 @@ namespace ICSharpCode.Data.Core.DatabaseObjects @@ -14,12 +17,23 @@ namespace ICSharpCode.Data.Core.DatabaseObjects
{
#region Fields
private string _query = string.Empty;
private string _definingQuery = string.Empty;
#endregion
#region Properties
public string Query
{
get { return _query; }
set
{
_query = value;
OnPropertyChanged("Query");
}
}
public string DefiningQuery
{
get { return _definingQuery; }

6
src/AddIns/DisplayBindings/Data/ICSharpCode.Data.Core/Interfaces/IView.cs

@ -1,4 +1,7 @@ @@ -1,4 +1,7 @@
#region Usings
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
#region Usings
using System;
using System.Collections.Generic;
@ -11,6 +14,7 @@ namespace ICSharpCode.Data.Core.Interfaces @@ -11,6 +14,7 @@ namespace ICSharpCode.Data.Core.Interfaces
{
public interface IView : ITable
{
string Query { get; set; }
string DefiningQuery { get; set; }
}
}

1
src/AddIns/DisplayBindings/Data/ICSharpCode.Data.DemoApp/ICSharpCode.Data.DemoApp.csproj

@ -59,6 +59,7 @@ @@ -59,6 +59,7 @@
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xaml" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp">
<RequiredTargetFramework>4.0</RequiredTargetFramework>

37
src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core/EDMObjects/SSDL/EntityType/EntityType.cs

@ -1,4 +1,7 @@ @@ -1,4 +1,7 @@
#region Usings
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
#region Usings
using System;
using System.Collections.Generic;
@ -43,7 +46,37 @@ namespace ICSharpCode.Data.EDMDesigner.Core.EDMObjects.SSDL.EntityType @@ -43,7 +46,37 @@ namespace ICSharpCode.Data.EDMDesigner.Core.EDMObjects.SSDL.EntityType
public string DefiningQuery
{
get { return _definingQuery; }
get
{
if (StoreType == null || StoreType == SSDL.EntityType.StoreType.Tables)
return _definingQuery;
if (string.IsNullOrEmpty(_definingQuery))
{
string definingQuery = string.Empty;
for (int i = 0; i < _properties.Count; i++)
{
if (string.IsNullOrEmpty(definingQuery))
definingQuery += "SELECT \r";
definingQuery += string.Format("[{0}].[{1}] AS [{1}]", _entitySetName, _properties[i].Name);
if (i < _properties.Count - 1)
{
definingQuery += ", \r";
}
else
{
definingQuery += string.Format(" \rFROM [{0}].[{1}] AS [{1}]", Schema, _entitySetName);
}
}
return definingQuery;
}
return _definingQuery;
}
set
{
_definingQuery = value;

8
src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core/ICSharpCode.Data.EDMDesigner.Core.csproj

@ -165,6 +165,7 @@ @@ -165,6 +165,7 @@
<Compile Include="EDMObjects\SSDL\Property\Property.cs" />
<Compile Include="EDMObjects\SSDL\Property\StoreGeneratedPattern.cs" />
<Compile Include="EDMObjects\SSDL\SSDLContainer.cs" />
<Compile Include="ObjectModelConverters\ObjectModelConverterException.cs" />
<Compile Include="ObjectModelConverters\SSDLConverter.cs" />
<Compile Include="ObjectModelConverters\EDMConverter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
@ -175,6 +176,9 @@ @@ -175,6 +176,9 @@
<DependentUpon>ChooseDatabaseObjectsUserControl.xaml</DependentUpon>
</Compile>
<Compile Include="Windows\EDMWizard\EDMWizardWindow.cs" />
<Compile Include="Windows\EDMWizard\EDMWizardErrorUserControl.xaml.cs">
<DependentUpon>EDMWizardErrorUserControl.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<Page Include="Windows\EDMWizard\ChooseDatabaseConnectionUserControl.xaml">
@ -185,6 +189,10 @@ @@ -185,6 +189,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Windows\EDMWizard\EDMWizardErrorUserControl.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\..\src\Main\Base\Project\ICSharpCode.SharpDevelop.csproj">

6
src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core/IO/CSDLIO.cs

@ -1,4 +1,7 @@ @@ -1,4 +1,7 @@
#region Usings
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
#region Usings
using System;
using System.Linq;
@ -124,6 +127,7 @@ namespace ICSharpCode.Data.EDMDesigner.Core.IO @@ -124,6 +127,7 @@ namespace ICSharpCode.Data.EDMDesigner.Core.IO
ReadCSDLType(schemaElement, entityTypeElement, container, (TypeBase)entityType);
return entityType;
}
private static void ReadCSDLType(XElement schemaElement, XElement entityTypeElement, CSDLContainer container, TypeBase baseType)
{
if (baseType.Name == null)

20
src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core/IO/EDMXIO.cs

@ -1,4 +1,7 @@ @@ -1,4 +1,7 @@
#region Usings
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
#region Usings
using System;
using System.Linq;
@ -35,7 +38,7 @@ namespace ICSharpCode.Data.EDMDesigner.Core.IO @@ -35,7 +38,7 @@ namespace ICSharpCode.Data.EDMDesigner.Core.IO
private static EDM Read(XElement edmx, Action<XElement> readMoreAction)
{
XElement edmxRuntime = edmx.Element(XName.Get("Runtime", "http://schemas.microsoft.com/ado/2007/06/edmx"));
XElement edmxRuntime = edmx.Element(XName.Get("Runtime", edmxNamespace.NamespaceName));
SSDLContainer ssdlContainer = SSDLIO.ReadXElement(edmxRuntime);
CSDLContainer csdlContainer = CSDLIO.ReadXElement(edmxRuntime);
@ -60,5 +63,18 @@ namespace ICSharpCode.Data.EDMDesigner.Core.IO @@ -60,5 +63,18 @@ namespace ICSharpCode.Data.EDMDesigner.Core.IO
readMoreAction(edmx);
return edm;
}
public static XDocument WriteXDocument(XDocument ssdlXDocument, XDocument csdlXDocument, XDocument mslXDocument)
{
return new XDocument(new XDeclaration("1.0", "utf-8", null),
new XElement(edmxNamespace + "Edmx", new XAttribute("Version", "1.0"), new XAttribute(XNamespace.Xmlns + "edmx", edmxNamespace.NamespaceName),
new XElement(edmxNamespace + "Runtime",
new XElement(edmxNamespace + "StorageModels",
ssdlXDocument.Root),
new XElement(edmxNamespace + "ConceptualModels",
csdlXDocument.Root),
new XElement(edmxNamespace + "Mappings",
mslXDocument.Root))));
}
}
}

13
src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core/IO/IO.cs

@ -1,4 +1,7 @@ @@ -1,4 +1,7 @@
#region Usings
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
#region Usings
using System;
using System.Linq;
@ -13,14 +16,14 @@ namespace ICSharpCode.Data.EDMDesigner.Core.IO @@ -13,14 +16,14 @@ namespace ICSharpCode.Data.EDMDesigner.Core.IO
{
#region Namespace declarations
protected static XNamespace edmxNamespace = "http://schemas.microsoft.com/ado/2007/06/edmx";
protected static XNamespace ssdlNamespace = "http://schemas.microsoft.com/ado/2006/04/edm/ssdl";
protected static XNamespace edmxNamespace = "http://schemas.microsoft.com/ado/2008/10/edmx";
protected static XNamespace ssdlNamespace = "http://schemas.microsoft.com/ado/2009/02/edm/ssdl";
protected static XNamespace storeNamespace = "http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator";
protected static XNamespace csdlNamespace = "http://schemas.microsoft.com/ado/2006/04/edm";
protected static XNamespace csdlNamespace = "http://schemas.microsoft.com/ado/2008/09/edm";
protected static XNamespace csdlCodeGenerationNamespace = "http://schemas.microsoft.com/ado/2006/04/codegeneration";
protected static XNamespace mslNamespace = "urn:schemas-microsoft-com:windows:storage:mapping:CS";
protected static XNamespace mslNamespace = "http://schemas.microsoft.com/ado/2008/09/mapping/cs";
#endregion

13
src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core/IO/SSDLIO.cs

@ -1,4 +1,7 @@ @@ -1,4 +1,7 @@
#region Usings
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
#region Usings
using System;
using System.Collections.Generic;
@ -46,12 +49,12 @@ namespace ICSharpCode.Data.EDMDesigner.Core.IO @@ -46,12 +49,12 @@ namespace ICSharpCode.Data.EDMDesigner.Core.IO
{
XElement entitySet = new XElement(ssdlNamespace + "EntitySet",
new XAttribute("Name", entityType.EntitySetName), new XAttribute("EntityType", string.Concat(entityContainerNamespace, entityType.Name)))
.AddAttribute("Schema", entityType.Schema)
.AddAttribute(entityType.StoreType == StoreType.Views ? null : new XAttribute("Schema", entityType.Schema))
.AddAttribute("Table", entityType.Table)
.AddAttribute(storeNamespace, "Name", entityType.StoreName)
.AddAttribute(storeNamespace, "Schema", entityType.StoreSchema)
.AddAttribute(storeNamespace, "Type", entityType.StoreType)
.AddElement(string.IsNullOrEmpty(entityType.DefiningQuery) ? null : new XElement("DefiningQuery", entityType.DefiningQuery));
.AddElement(string.IsNullOrEmpty(entityType.DefiningQuery) ? null : new XElement(ssdlNamespace + "DefiningQuery", entityType.DefiningQuery));
entityContainer.Add(entitySet);
}
@ -84,7 +87,9 @@ namespace ICSharpCode.Data.EDMDesigner.Core.IO @@ -84,7 +87,9 @@ namespace ICSharpCode.Data.EDMDesigner.Core.IO
foreach (Property property in entityType.Properties)
{
if (property.IsKey)
// If we have a table then we set a key element if the current property is a primary key or part of a composite key.
// AND: If we have a view then we make a composite key of all non-nullable properties of the entity (VS2010 is also doing this).
if ((entityType.StoreType == StoreType.Tables && property.IsKey) || (entityType.StoreType == StoreType.Views && property.Nullable == false))
keys.Add(new XElement(ssdlNamespace + "PropertyRef", new XAttribute("Name", property.Name)));
}

23
src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core/ObjectModelConverters/EDMConverter.cs

@ -1,4 +1,7 @@ @@ -1,4 +1,7 @@
#region Usings
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
#region Usings
using System;
using System.Collections.Generic;
@ -46,7 +49,6 @@ namespace ICSharpCode.Data.EDMDesigner.Core.ObjectModelConverters @@ -46,7 +49,6 @@ namespace ICSharpCode.Data.EDMDesigner.Core.ObjectModelConverters
string filenameRump = Path.GetTempPath() + fileInfo.Name.Replace(fileInfo.Extension, string.Empty);
string edmGenPath = RuntimeEnvironment.GetRuntimeDirectory() + "\\EdmGen.exe";
edmGenPath = @"C:\Windows\Microsoft.NET\Framework\v3.5\EdmGen.exe";
Process process = new Process();
ProcessStartInfo processStartInfo = new ProcessStartInfo();
@ -65,26 +67,15 @@ namespace ICSharpCode.Data.EDMDesigner.Core.ObjectModelConverters @@ -65,26 +67,15 @@ namespace ICSharpCode.Data.EDMDesigner.Core.ObjectModelConverters
if (process.ExitCode != 0)
{
throw new Exception("An error occured during generating the EDMX file.", new Exception(outputMessage));
throw new ObjectModelConverterException(string.Format("An error occured during generating the EDMX file from \"{0}.ssdl\".", filenameRump),
outputMessage, ObjectModelConverterExceptionEnum.EDM);
}
XDocument csdlXDocument = XDocument.Load(filenameRump + ".csdl");
XDocument mslXDocument = XDocument.Load(filenameRump + ".msl");
mslXDocument = MSLIO.GenerateTypeMapping(mslXDocument);
XNamespace edmxNamespace = "http://schemas.microsoft.com/ado/2007/06/edmx";
XDocument edmXDocument = new XDocument(new XDeclaration("1.0", "utf-8", null),
new XElement(edmxNamespace + "Edmx", new XAttribute("Version", "1.0"), new XAttribute(XNamespace.Xmlns + "edmx", edmxNamespace.NamespaceName),
new XElement(edmxNamespace + "Runtime",
new XElement(edmxNamespace + "StorageModels",
ssdlXDocument.Root),
new XElement(edmxNamespace + "ConceptualModels",
csdlXDocument.Root),
new XElement(edmxNamespace + "Mappings",
mslXDocument.Root))));
return edmXDocument;
return EDMXIO.WriteXDocument(ssdlXDocument, csdlXDocument, mslXDocument);
}
private static string GetTempFilename()

39
src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core/ObjectModelConverters/ObjectModelConverterException.cs

@ -0,0 +1,39 @@ @@ -0,0 +1,39 @@
#region Usings
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
#endregion
namespace ICSharpCode.Data.EDMDesigner.Core.ObjectModelConverters
{
public enum ObjectModelConverterExceptionEnum
{
CSDL,
EDM,
SSDL
}
public class ObjectModelConverterException : Exception
{
#region Constructor
public ObjectModelConverterException(string message, string detail, ObjectModelConverterExceptionEnum type) : base(message)
{
Detail = detail;
ExceptionType = type;
}
#endregion
#region Properties
public string FullMessage { get { return Message + "\n\nDetailed error message:\n" + Detail; } }
public string Detail { get; protected set; }
public ObjectModelConverterExceptionEnum ExceptionType { get; protected set; }
#endregion
}
}

9
src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core/ObjectModelConverters/SSDLConverter.cs

@ -1,4 +1,7 @@ @@ -1,4 +1,7 @@
#region Usings
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
#region Usings
using System.Collections.Generic;
@ -75,7 +78,9 @@ namespace ICSharpCode.Data.EDMDesigner.Core.ObjectModelConverters @@ -75,7 +78,9 @@ namespace ICSharpCode.Data.EDMDesigner.Core.ObjectModelConverters
{
Name = table.TableName,
EntitySetName = table.TableName,
Schema = table.SchemaName
Schema = table.SchemaName,
StoreName = table.TableName,
StoreSchema = table.SchemaName
};
if (table is IView)

7
src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core/Windows/EDMWizard/ChooseDatabaseObjectsUserControl.xaml.cs

@ -1,4 +1,7 @@ @@ -1,4 +1,7 @@
using System;
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -49,7 +52,7 @@ namespace ICSharpCode.Data.EDMDesigner.Core.Windows.EDMWizard @@ -49,7 +52,7 @@ namespace ICSharpCode.Data.EDMDesigner.Core.Windows.EDMWizard
InitializeComponent();
}
public override void OnActivate()
public override void OnActivateFromPredecessor()
{
EDMWizardWindow edmWizardWindow = WizardWindow as EDMWizardWindow;
if (edmWizardWindow.SelectedDatabase != null)

14
src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core/Windows/EDMWizard/EDMWizardErrorUserControl.xaml

@ -0,0 +1,14 @@ @@ -0,0 +1,14 @@
<data:WizardErrorUserControl x:Class="ICSharpCode.Data.EDMDesigner.Core.Windows.EDMWizard.EDMWizardErrorUserControl" x:Name="This"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:data="http://icsharpcode.net/data">
<Grid Margin="5">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Margin="3">The following error(s) occured during generation of the Entity Data Model:</TextBlock>
<TextBox Grid.Row="1" Margin="3" Text="{Binding Path=Exception.FullMessage, ElementName=This, Mode=OneWay}" IsReadOnly="True" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" />
</Grid>
</data:WizardErrorUserControl>

44
src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core/Windows/EDMWizard/EDMWizardErrorUserControl.xaml.cs

@ -0,0 +1,44 @@ @@ -0,0 +1,44 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ICSharpCode.Data.Core.UI.UserControls;
namespace ICSharpCode.Data.EDMDesigner.Core.Windows.EDMWizard
{
/// <summary>
/// Interaction logic for EDMWizardErrorUserControl.xaml
/// </summary>
public partial class EDMWizardErrorUserControl : WizardErrorUserControl
{
public override string Title
{
get
{
return "Error while generating Entity Model";
}
}
public EDMWizardErrorUserControl()
{
InitializeComponent();
}
public override void OnActivate()
{
}
}
}

23
src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core/Windows/EDMWizard/EDMWizardWindow.cs

@ -1,4 +1,7 @@ @@ -1,4 +1,7 @@
#region Usings
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
#region Usings
using System;
using System.Collections.Generic;
@ -139,6 +142,7 @@ namespace ICSharpCode.Data.EDMDesigner.Core.Windows.EDMWizard @@ -139,6 +142,7 @@ namespace ICSharpCode.Data.EDMDesigner.Core.Windows.EDMWizard
Title = "Entity Framework Wizard";
Width = 640;
Height = 480;
WizardWindowInnards.WizardErrorUserControl = new EDMWizardErrorUserControl();
AddWizardUserControl<ChooseDatabaseConnectionUserControl>();
AddWizardUserControl<ChooseDatabaseObjectsUserControl>();
@ -147,23 +151,6 @@ namespace ICSharpCode.Data.EDMDesigner.Core.Windows.EDMWizard @@ -147,23 +151,6 @@ namespace ICSharpCode.Data.EDMDesigner.Core.Windows.EDMWizard
#endregion
#region Event handlers
private void btnNewConnection_Click(object sender, RoutedEventArgs e)
{
ConnectionWizardWindow connectionWizardWindow = new ConnectionWizardWindow();
connectionWizardWindow.Owner = this;
connectionWizardWindow.ShowDialog();
if (connectionWizardWindow.DialogResult.HasValue && connectionWizardWindow.DialogResult.Value)
{
_databases.Add(connectionWizardWindow.SelectedDatabase);
SelectedDatabase = connectionWizardWindow.SelectedDatabase;
}
}
#endregion
#region Methods
public override void OnFinished()

28
src/AddIns/DisplayBindings/Data/ICSharpCode.Data.SQLServer/SQLServerDatabaseDriver.cs

@ -1,4 +1,7 @@ @@ -1,4 +1,7 @@
#region Usings
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
#region Usings
using System;
using System.Collections.Generic;
@ -110,6 +113,7 @@ namespace ICSharpCode.Data.Core.DatabaseDrivers.SQLServer @@ -110,6 +113,7 @@ namespace ICSharpCode.Data.Core.DatabaseDrivers.SQLServer
1,2,3,4";
private const string _getViews = @"SELECT TABLE_SCHEMA, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='VIEW' AND TABLE_NAME<>'dtproperties' ORDER BY TABLE_SCHEMA, TABLE_NAME";
private const string _getViewDefiningQuery = @"EXEC sp_helptext '{0}'";
private const string _getProcedures = "SELECT ROUTINE_NAME, ROUTINE_SCHEMA, ROUTINE_BODY, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_TYPE = 'PROCEDURE'";
private const string _getProcedureParameters = @"SELECT PARAMETER_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, PARAMETER_MODE, IS_RESULT FROM information_schema.PARAMETERS WHERE SPECIFIC_NAME = '{0}' AND SPECIFIC_SCHEMA = '{1}' AND SPECIFIC_CATALOG = '{2}'";
@ -357,9 +361,8 @@ namespace ICSharpCode.Data.Core.DatabaseDrivers.SQLServer @@ -357,9 +361,8 @@ namespace ICSharpCode.Data.Core.DatabaseDrivers.SQLServer
string schemaName = (string)dtViews.Rows[i]["TABLE_SCHEMA"];
string viewName = (string)dtViews.Rows[i]["TABLE_NAME"];
View view = new View() { SchemaName = schemaName, TableName = viewName };
View view = new View() { SchemaName = schemaName, TableName = viewName, Query = LoadViewQuery(sqlConnection, schemaName, viewName) };
LoadColumns(sqlConnection, view, TableType.View);
views.Add(view);
}
}
@ -367,6 +370,25 @@ namespace ICSharpCode.Data.Core.DatabaseDrivers.SQLServer @@ -367,6 +370,25 @@ namespace ICSharpCode.Data.Core.DatabaseDrivers.SQLServer
return views;
}
private string LoadViewQuery(SqlConnection sqlConnection, string schemaName, string tableName)
{
string definingQuery = string.Empty;
using (SqlDataAdapter dataAdapter =
new SqlDataAdapter(string.Format(_getViewDefiningQuery, schemaName + "." + tableName), sqlConnection))
{
DataTable dtQuery = new DataTable("Text");
dataAdapter.Fill(dtQuery);
for (int i = 0; i < dtQuery.Rows.Count; i++)
{
definingQuery += (string)dtQuery.Rows[i]["Text"];
}
}
return definingQuery;
}
public override DatabaseObjectsCollection<IProcedure> LoadProcedures(IDatabase database)
{
DatabaseObjectsCollection<IProcedure> procedures = new DatabaseObjectsCollection<IProcedure>(database);

Loading…
Cancel
Save