Browse Source

EMD Designer: Several bugfixes concerning wizard/template problems when generating a new EDMX from database

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4716 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Philipp Maihart 16 years ago
parent
commit
16f7f35979
  1. 8
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.Addin/Templates/Files/CSharp.EDMX.xft
  2. 3
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.Core.UI/UserControls/DatabaseTreeViewResources.xaml
  3. 2
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.Core/DatabaseObjects/DatabaseObjectBase.cs
  4. 23
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.Core/DatabaseObjects/Table.cs
  5. 19
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.Core/DatabaseObjects/View.cs
  6. 1
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.Core/Interfaces/ITable.cs
  7. 1
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.Core/Interfaces/IView.cs
  8. 28
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core.UI/DisplayBinding/EDMDesignerViewContent.cs
  9. 6
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core.UI/UserControls/CSDLType/TypeBaseDesigner.xaml.cs
  10. 78
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core.UI/UserControls/DesignerCanvas.cs
  11. 9
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core/EDMObjects/Designer/Common/UIBusinessType.cs
  12. 35
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core/IO/DesignerIO.cs
  13. 28
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core/IO/SSDLIO.cs
  14. 2
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core/ObjectModelConverters/EDMConverter.cs
  15. 7
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core/ObjectModelConverters/SSDLConverter.cs

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

@ -20,7 +20,9 @@
${Path} -> Full path of the file ${Path} -> Full path of the file
--> -->
<Files> <Files>
<File name="${FullName}" language="XML" buildAction="Page"><![CDATA[<?xml version="1.0" encoding="utf-8"?> <!--<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/2007/06/edmx">
<!-- EF Runtime content --> <!-- EF Runtime content -->
<edmx:Runtime> <edmx:Runtime>
@ -32,8 +34,8 @@
<edmx:Mappings /> <edmx:Mappings />
</edmx:Runtime> </edmx:Runtime>
<DesignerViews /> <DesignerViews />
</edmx:Edmx>]]></File> </edmx:Edmx>]]>
<File name="${FileNameWithoutExtension}.Designer.cs" language="C#" DependentUpon="${FileName}" SubType="Code"><![CDATA[${StandardHeader.C#}]]></File> </File>
</Files> </Files>
<AdditionalOptions/> <AdditionalOptions/>

3
src/AddIns/DisplayBindings/Data/ICSharpCode.Data.Core.UI/UserControls/DatabaseTreeViewResources.xaml

@ -59,6 +59,9 @@
<DataTrigger Binding="{Binding ShowCheckBoxes, RelativeSource={RelativeSource AncestorType=TreeView}}" Value="True"> <DataTrigger Binding="{Binding ShowCheckBoxes, RelativeSource={RelativeSource AncestorType=TreeView}}" Value="True">
<Setter Property="Visibility" TargetName="chkIsSelected" Value="Visible" /> <Setter Property="Visibility" TargetName="chkIsSelected" Value="Visible" />
</DataTrigger> </DataTrigger>
<DataTrigger Binding="{Binding HasKeyDefined}" Value="False">
<Setter Property="IsEnabled" TargetName="chkIsSelected" Value="False" />
</DataTrigger>
</HierarchicalDataTemplate.Triggers> </HierarchicalDataTemplate.Triggers>
</HierarchicalDataTemplate> </HierarchicalDataTemplate>
<DataTemplate x:Key="ColumnDataTemplate"> <DataTemplate x:Key="ColumnDataTemplate">

2
src/AddIns/DisplayBindings/Data/ICSharpCode.Data.Core/DatabaseObjects/DatabaseObjectBase.cs

@ -39,7 +39,7 @@ namespace ICSharpCode.Data.Core.DatabaseObjects
} }
} }
public bool IsSelected public virtual bool IsSelected
{ {
get { return _isSelected; } get { return _isSelected; }
set set

23
src/AddIns/DisplayBindings/Data/ICSharpCode.Data.Core/DatabaseObjects/Table.cs

@ -61,6 +61,29 @@ namespace ICSharpCode.Data.Core.DatabaseObjects
get { return string.Format("[{0}].[{1}]", _schemaName, _tableName); } get { return string.Format("[{0}].[{1}]", _schemaName, _tableName); }
} }
public bool HasKeyDefined
{
get
{
if (Items.FirstOrDefault(column => column.IsPrimaryKey) != null)
return true;
else
return false;
}
}
public override bool IsSelected
{
get
{
if (HasKeyDefined || GetType().GetInterface("IView") != null)
return base.IsSelected;
else
return false;
}
set { base.IsSelected = value; }
}
#endregion #endregion
#region IDatabaseObjectBase Members #region IDatabaseObjectBase Members

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

@ -12,5 +12,24 @@ namespace ICSharpCode.Data.Core.DatabaseObjects
{ {
public class View : Table, IView public class View : Table, IView
{ {
#region Fields
private string _definingQuery = string.Empty;
#endregion
#region Properties
public string DefiningQuery
{
get { return _definingQuery; }
set
{
_definingQuery = value;
OnPropertyChanged("DefiningQuery");
}
}
#endregion
} }
} }

1
src/AddIns/DisplayBindings/Data/ICSharpCode.Data.Core/Interfaces/ITable.cs

@ -16,5 +16,6 @@ namespace ICSharpCode.Data.Core.Interfaces
string TableName { get; set; } string TableName { get; set; }
string SchemaName { get; set; } string SchemaName { get; set; }
DatabaseObjectsCollection<IConstraint> Constraints { get; } DatabaseObjectsCollection<IConstraint> Constraints { get; }
bool HasKeyDefined { get; }
} }
} }

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

@ -11,5 +11,6 @@ namespace ICSharpCode.Data.Core.Interfaces
{ {
public interface IView : ITable public interface IView : ITable
{ {
string DefiningQuery { get; set; }
} }
} }

28
src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core.UI/DisplayBinding/EDMDesignerViewContent.cs

@ -94,34 +94,40 @@ namespace ICSharpCode.Data.EDMDesigner.Core.UI.DisplayBinding
{ {
Debug.Assert(file == this.PrimaryFile); Debug.Assert(file == this.PrimaryFile);
// Load EDMX from stream
XElement edmxElement = null; XElement edmxElement = null;
Action<XElement> readMoreAction = edmxElt => edmxElement = edmxElt; Action<XElement> readMoreAction = edmxElt => edmxElement = edmxElt;
_edmView = new EDMView(stream, readMoreAction); _edmView = new EDMView(stream, readMoreAction);
// If EDMX is empty run EDM Wizard
if (_edmView.EDM.IsEmpty) if (_edmView.EDM.IsEmpty)
{ {
edmxElement = null; edmxElement = null;
EDMWizardWindow wizard = RunWizard(file); EDMWizardWindow wizard = RunWizard(file);
if (wizard.DialogResult == true) if (wizard.DialogResult == true)
{ _edmView = new EDMView(wizard.EDMXDocument, readMoreAction);
_edmView = new EDMView(wizard.EDMXDocument, readMoreAction);
//wizard.EDMXDocument.Save("C:\\temp\\test.edmx");
}
} }
// Load or generate DesignerView and EntityTypeDesigners
EntityTypeDesigner.Init = true; EntityTypeDesigner.Init = true;
if (edmxElement.Element("DesignerViews") == null)
edmxElement = new XElement("Designer", DesignerIO.GenerateNewDesignerViewsFromCSDLView(_edmView.CSDL));
if (edmxElement != null && edmxElement.Element("DesignerViews") != null) if (edmxElement != null && edmxElement.Element("DesignerViews") != null)
DesignerIO.Read(_edmView, edmxElement.Element("DesignerViews"), entityType => new EntityTypeDesigner(entityType), complexType => new ComplexTypeDesigner(complexType)); DesignerIO.Read(_edmView, edmxElement.Element("DesignerViews"), entityType => new EntityTypeDesigner(entityType), complexType => new ComplexTypeDesigner(complexType));
EntityTypeDesigner.Init = false; EntityTypeDesigner.Init = false;
//VisualHelper.DoEvents(); // Call DoEvents, otherwise drawing associations can fail
VisualHelper.DoEvents();
// Gets the designer canvas
_designerCanvas = DesignerCanvas.GetDesignerCanvas(this, _edmView, _edmView.DesignerViews.FirstOrDefault()); _designerCanvas = DesignerCanvas.GetDesignerCanvas(this, _edmView, _edmView.DesignerViews.FirstOrDefault());
_scrollViewer.Content = _designerCanvas; _scrollViewer.Content = _designerCanvas;
// Register CSDL of EDMX in CSDL DatabaseTreeView
CSDLDatabaseTreeViewAdditionalNode.Instance.CSDLViews.Add(_edmView.CSDL); CSDLDatabaseTreeViewAdditionalNode.Instance.CSDLViews.Add(_edmView.CSDL);
} }

6
src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core.UI/UserControls/CSDLType/TypeBaseDesigner.xaml.cs

@ -16,6 +16,7 @@ using ICSharpCode.Data.EDMDesigner.Core.EDMObjects.Designer.CSDL.Property;
using ICSharpCode.Data.EDMDesigner.Core.EDMObjects.Designer.CSDL.Type; using ICSharpCode.Data.EDMDesigner.Core.EDMObjects.Designer.CSDL.Type;
using ICSharpCode.Data.EDMDesigner.Core.UI.UserControls.Common; using ICSharpCode.Data.EDMDesigner.Core.UI.UserControls.Common;
using ICSharpCode.Data.EDMDesigner.Core.UI.UserControls.Relations; using ICSharpCode.Data.EDMDesigner.Core.UI.UserControls.Relations;
using ICSharpCode.Data.Core.UI;
#endregion #endregion
@ -197,6 +198,11 @@ namespace ICSharpCode.Data.EDMDesigner.Core.UI.UserControls.CSDLType
internal ListViewItem GetListViewItem(NavigationProperty navigationProperty, out int index) internal ListViewItem GetListViewItem(NavigationProperty navigationProperty, out int index)
{ {
foreach (ListViewItem lvia in VisualTreeHelperUtil.GetControlsDecendant<ListViewItem>(propertiesListView))
{
lvia.ToString();
}
var value = (from lvi in VisualTreeHelperUtil.GetControlsDecendant<ListViewItem>(propertiesListView) var value = (from lvi in VisualTreeHelperUtil.GetControlsDecendant<ListViewItem>(propertiesListView)
let uiRelatedProperty = lvi.Content as UIRelatedProperty let uiRelatedProperty = lvi.Content as UIRelatedProperty
where uiRelatedProperty != null where uiRelatedProperty != null

78
src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core.UI/UserControls/DesignerCanvas.cs

@ -71,15 +71,15 @@ namespace ICSharpCode.Data.EDMDesigner.Core.UI.UserControls
var designerView = (DesignerView)e.NewValue; var designerView = (DesignerView)e.NewValue;
foreach (TypeBaseDesigner typeBaseDesigner in designerView) foreach (TypeBaseDesigner typeBaseDesigner in designerView)
designerCanvas.Children.Add(typeBaseDesigner); designerCanvas.Children.Add(typeBaseDesigner);
designerCanvas.Loaded += //designerCanvas.Loaded +=
delegate // delegate
{ // {
VisualHelper.DoEvents(); // VisualHelper.DoEvents();
foreach (TypeBaseDesigner typeBaseDesigner in designerView) // foreach (TypeBaseDesigner typeBaseDesigner in designerView)
typeBaseDesigner.DrawRelations(); // typeBaseDesigner.DrawRelations();
designerCanvas.Zoom = designerView.Zoom; // designerCanvas.Zoom = designerView.Zoom;
}; // };
})); }));
private static Dictionary<DesignerView, DesignerCanvas> _designerCanvas = new Dictionary<DesignerView, DesignerCanvas>(); private static Dictionary<DesignerView, DesignerCanvas> _designerCanvas = new Dictionary<DesignerView, DesignerCanvas>();
@ -88,18 +88,25 @@ namespace ICSharpCode.Data.EDMDesigner.Core.UI.UserControls
{ {
DesignerCanvas designerCanvas = null; DesignerCanvas designerCanvas = null;
if (designerView == null) //if (designerView == null)
{ //{
designerView = new DesignerView(); // EntityTypeDesigner.Init = true;
designerView.ArrangeTypeDesigners = true;
designerView.Name = edmView.Name;
designerView.Zoom = 100;
foreach(UIEntityType entityType in edmView.CSDL.EntityTypes) // designerView = new DesignerView();
{ // designerView.ArrangeTypeDesigners = true;
designerView.AddTypeDesigner(new EntityTypeDesigner(entityType) { IsExpanded = true }); // designerView.Name = edmView.Name;
} // designerView.Zoom = 100;
}
// if (edmView.CSDL.CSDL != null)
// {
// foreach (UIEntityType entityType in edmView.CSDL.EntityTypes)
// {
// designerView.AddTypeDesigner(new EntityTypeDesigner(entityType) { IsExpanded = true });
// }
// }
// EntityTypeDesigner.Init = false;
//}
if (designerView != null && _designerCanvas.ContainsKey(designerView)) if (designerView != null && _designerCanvas.ContainsKey(designerView))
{ {
@ -314,29 +321,38 @@ namespace ICSharpCode.Data.EDMDesigner.Core.UI.UserControls
} }
private void DesignerCanvas_Loaded(object sender, RoutedEventArgs e) private void DesignerCanvas_Loaded(object sender, RoutedEventArgs e)
{ {
if (DesignerView.ArrangeTypeDesigners) if (DesignerView.ArrangeTypeDesigners)
{ {
double left = 20, top = 20; double left = 20, top = 20;
double currentRowsMaxHeight = 0; double currentRowsMaxHeight = 0;
EntityTypeDesigner.Init = true;
foreach(EntityTypeDesigner entityTypeDesigner in DesignerView.TypeDesignersLocations) foreach(EntityTypeDesigner entityTypeDesigner in DesignerView.TypeDesignersLocations)
{ {
entityTypeDesigner.Left = left; entityTypeDesigner.Left = left;
entityTypeDesigner.Top = top; entityTypeDesigner.Top = top;
if (entityTypeDesigner.ActualHeight > currentRowsMaxHeight) if (entityTypeDesigner.ActualHeight > currentRowsMaxHeight)
currentRowsMaxHeight = entityTypeDesigner.ActualHeight; currentRowsMaxHeight = entityTypeDesigner.ActualHeight;
left += entityTypeDesigner.ActualWidth + 20; left += entityTypeDesigner.ActualWidth + 20;
if (left > ActualWidth) if (left > ActualWidth)
{ {
top += currentRowsMaxHeight + 20; top += currentRowsMaxHeight + 20;
left = 20; left = 20;
} }
} }
EntityTypeDesigner.Init = false;
} }
foreach (TypeBaseDesigner typeBaseDesigner in DesignerView)
typeBaseDesigner.DrawRelations();
(sender as DesignerCanvas).Zoom = DesignerView.Zoom;
} }
protected override void OnPreviewMouseDown(MouseButtonEventArgs e) protected override void OnPreviewMouseDown(MouseButtonEventArgs e)

9
src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core/EDMObjects/Designer/Common/UIBusinessType.cs

@ -27,19 +27,12 @@ namespace ICSharpCode.Data.EDMDesigner.Core.EDMObjects.Designer.Common
public BusinessType BusinessInstance { get; private set; } public BusinessType BusinessInstance { get; private set; }
public virtual string Name public override string Name
{ {
get { return BusinessInstance.Name; } get { return BusinessInstance.Name; }
set { BusinessInstance.Name = value; } set { BusinessInstance.Name = value; }
} }
protected virtual void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
public event PropertyChangedEventHandler PropertyChanged;
public override string ToString() public override string ToString()
{ {
return Name; return Name;

35
src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core/IO/DesignerIO.cs

@ -7,6 +7,7 @@ using System.Windows;
using System.Xml.Linq; using System.Xml.Linq;
using ICSharpCode.Data.EDMDesigner.Core.EDMObjects.Designer; using ICSharpCode.Data.EDMDesigner.Core.EDMObjects.Designer;
using ICSharpCode.Data.EDMDesigner.Core.EDMObjects.Designer.CSDL.Type; using ICSharpCode.Data.EDMDesigner.Core.EDMObjects.Designer.CSDL.Type;
using ICSharpCode.Data.EDMDesigner.Core.EDMObjects.Designer.CSDL;
#endregion #endregion
@ -26,12 +27,25 @@ namespace ICSharpCode.Data.EDMDesigner.Core.IO
public static DesignerView Read(EDMView edmView, Func<UIEntityType, ITypeDesigner> createEntityDesignerFromUIType, Func<UIComplexType, ITypeDesigner> createComplexDesignerFromUIType, XElement designerViewXElement) public static DesignerView Read(EDMView edmView, Func<UIEntityType, ITypeDesigner> createEntityDesignerFromUIType, Func<UIComplexType, ITypeDesigner> createComplexDesignerFromUIType, XElement designerViewXElement)
{ {
var designerView = new DesignerView { Name = designerViewXElement.Attribute("Name").Value, Zoom = int.Parse(designerViewXElement.Attribute("Zoom").Value) }; var designerView = new DesignerView()
{
Name = designerViewXElement.Attribute("Name").Value,
Zoom = int.Parse(designerViewXElement.Attribute("Zoom").Value)
};
var arrange = designerViewXElement.Attribute("Arrange");
if (arrange != null)
designerView.ArrangeTypeDesigners = bool.Parse(arrange.Value);
foreach (var designerTypeXElement in designerViewXElement.Elements("DesignerType")) foreach (var designerTypeXElement in designerViewXElement.Elements("DesignerType"))
{ {
var name = designerTypeXElement.Attribute("Name").Value; var name = designerTypeXElement.Attribute("Name").Value;
ITypeDesigner typeDesigner; ITypeDesigner typeDesigner;
var entityType = edmView.CSDL.EntityTypes.FirstOrDefault(et => et.Name == name); var entityType = edmView.CSDL.EntityTypes.FirstOrDefault(et => et.Name == name);
if (entityType != null) if (entityType != null)
typeDesigner = createEntityDesignerFromUIType(entityType); typeDesigner = createEntityDesignerFromUIType(entityType);
else else
@ -41,13 +55,19 @@ namespace ICSharpCode.Data.EDMDesigner.Core.IO
continue; continue;
typeDesigner = createComplexDesignerFromUIType(complexType); typeDesigner = createComplexDesignerFromUIType(complexType);
} }
var leftAttribute = designerTypeXElement.Attribute("Left").Value; var leftAttribute = designerTypeXElement.Attribute("Left").Value;
if (leftAttribute != null) if (leftAttribute != null)
typeDesigner.Left = double.Parse(leftAttribute, CultureInfo.InvariantCulture); typeDesigner.Left = double.Parse(leftAttribute, CultureInfo.InvariantCulture);
var topAttribute = designerTypeXElement.Attribute("Top").Value; var topAttribute = designerTypeXElement.Attribute("Top").Value;
if (topAttribute != null) if (topAttribute != null)
typeDesigner.Top = double.Parse(topAttribute, CultureInfo.InvariantCulture); typeDesigner.Top = double.Parse(topAttribute, CultureInfo.InvariantCulture);
var isExpandedAttribute = designerTypeXElement.Attribute("IsExpanded"); var isExpandedAttribute = designerTypeXElement.Attribute("IsExpanded");
if (isExpandedAttribute != null) if (isExpandedAttribute != null)
{ {
RoutedEventHandler loaded = null; RoutedEventHandler loaded = null;
@ -58,9 +78,22 @@ namespace ICSharpCode.Data.EDMDesigner.Core.IO
}; };
typeDesigner.Loaded += loaded; typeDesigner.Loaded += loaded;
} }
designerView.TypeDesignersLocations.Add(typeDesigner); designerView.TypeDesignersLocations.Add(typeDesigner);
} }
return designerView; return designerView;
} }
public static XElement GenerateNewDesignerViewsFromCSDLView(CSDLView csdl)
{
XElement designerView = new XElement("DesignerView", new XAttribute("Name", "View"), new XAttribute("Zoom", 100), new XAttribute("Arrange", true));
foreach (UIEntityType entityType in csdl.EntityTypes)
{
designerView.Add(new XElement("DesignerType", new XAttribute("Name", entityType.Name), new XAttribute("Top", 0), new XAttribute("Left", 0), new XAttribute("IsExpanded", true)));
}
return new XElement("DesignerViews", designerView);
}
} }
} }

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

@ -60,9 +60,17 @@ namespace ICSharpCode.Data.EDMDesigner.Core.IO
foreach (Association association in ssdlContainer.AssociationSets) foreach (Association association in ssdlContainer.AssociationSets)
{ {
XElement associationSet = new XElement(ssdlNamespace + "AssociationSet", XElement associationSet = new XElement(ssdlNamespace + "AssociationSet",
new XAttribute("Name", association.AssociationSetName), new XAttribute("Association", string.Concat(entityContainerNamespace, association.Name)), new XAttribute("Name", association.AssociationSetName), new XAttribute("Association", string.Concat(entityContainerNamespace, association.Name)));
string role2Name = association.Role2.Name;
// If the assocation end properties are the same properties
if (association.Role1.Name == association.Role2.Name && association.Role1.Type.Name == association.Role2.Type.Name)
role2Name += "1";
associationSet.Add(
new XElement(ssdlNamespace + "End", new XAttribute("Role", association.Role1.Name), new XAttribute("EntitySet", association.Role1.Type.Name)), new XElement(ssdlNamespace + "End", new XAttribute("Role", association.Role1.Name), new XAttribute("EntitySet", association.Role1.Type.Name)),
new XElement(ssdlNamespace + "End", new XAttribute("Role", association.Role2.Name), new XAttribute("EntitySet", association.Role2.Type.Name))); new XElement(ssdlNamespace + "End", new XAttribute("Role", role2Name), new XAttribute("EntitySet", association.Role2.Type.Name)));
entityContainer.Add(associationSet); entityContainer.Add(associationSet);
} }
@ -105,14 +113,26 @@ namespace ICSharpCode.Data.EDMDesigner.Core.IO
foreach (Association association in ssdlContainer.AssociationSets) foreach (Association association in ssdlContainer.AssociationSets)
{ {
string role2Name = association.Role2.Name;
// If the assocation end properties are the same properties
if (association.Role1.Name == association.Role2.Name && association.Role1.Type.Name == association.Role2.Type.Name)
role2Name += "1";
XElement associationElement = new XElement(ssdlNamespace + "Association", new XAttribute("Name", association.Name), XElement associationElement = new XElement(ssdlNamespace + "Association", new XAttribute("Name", association.Name),
new XElement(ssdlNamespace + "End", new XAttribute("Role", association.Role1.Name), new XAttribute("Type", string.Concat(entityContainerNamespace, association.Role1.Type.Name)), new XAttribute("Multiplicity", CardinalityStringConverter.CardinalityToSTring(association.Role1.Cardinality))), new XElement(ssdlNamespace + "End", new XAttribute("Role", association.Role1.Name), new XAttribute("Type", string.Concat(entityContainerNamespace, association.Role1.Type.Name)), new XAttribute("Multiplicity", CardinalityStringConverter.CardinalityToSTring(association.Role1.Cardinality))),
new XElement(ssdlNamespace + "End", new XAttribute("Role", association.Role2.Name), new XAttribute("Type", string.Concat(entityContainerNamespace, association.Role2.Type.Name)), new XAttribute("Multiplicity", CardinalityStringConverter.CardinalityToSTring(association.Role2.Cardinality)))); new XElement(ssdlNamespace + "End", new XAttribute("Role", role2Name), new XAttribute("Type", string.Concat(entityContainerNamespace, association.Role2.Type.Name)), new XAttribute("Multiplicity", CardinalityStringConverter.CardinalityToSTring(association.Role2.Cardinality))));
string dependantRoleName = association.DependantRole.Name;
// If the assocation end properties are the same properties
if (association.PrincipalRole.Name == association.DependantRole.Name && association.PrincipalRole.Type.Name == association.DependantRole.Type.Name)
dependantRoleName += "1";
associationElement.Add(new XElement(ssdlNamespace + "ReferentialConstraint", associationElement.Add(new XElement(ssdlNamespace + "ReferentialConstraint",
new XElement(ssdlNamespace + "Principal", new XAttribute("Role", association.PrincipalRole.Name), new XElement(ssdlNamespace + "Principal", new XAttribute("Role", association.PrincipalRole.Name),
new XElement(ssdlNamespace + "PropertyRef", new XAttribute("Name", association.PrincipalRole.Property.Name))), new XElement(ssdlNamespace + "PropertyRef", new XAttribute("Name", association.PrincipalRole.Property.Name))),
new XElement(ssdlNamespace + "Dependent", new XAttribute("Role", association.DependantRole.Name), new XElement(ssdlNamespace + "Dependent", new XAttribute("Role", dependantRoleName),
new XElement(ssdlNamespace + "PropertyRef", new XAttribute("Name", association.DependantRole.Property.Name))))); new XElement(ssdlNamespace + "PropertyRef", new XAttribute("Name", association.DependantRole.Property.Name)))));
schema.Add(associationElement); schema.Add(associationElement);

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

@ -48,8 +48,6 @@ namespace ICSharpCode.Data.EDMDesigner.Core.ObjectModelConverters
string edmGenPath = RuntimeEnvironment.GetRuntimeDirectory() + "\\EdmGen.exe"; string edmGenPath = RuntimeEnvironment.GetRuntimeDirectory() + "\\EdmGen.exe";
edmGenPath = @"C:\Windows\Microsoft.NET\Framework\v3.5\EdmGen.exe"; edmGenPath = @"C:\Windows\Microsoft.NET\Framework\v3.5\EdmGen.exe";
StreamReader streamReader = null;
Process process = new Process(); Process process = new Process();
ProcessStartInfo processStartInfo = new ProcessStartInfo(); ProcessStartInfo processStartInfo = new ProcessStartInfo();
processStartInfo.WorkingDirectory = Path.GetTempPath(); processStartInfo.WorkingDirectory = Path.GetTempPath();

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

@ -36,7 +36,7 @@ namespace ICSharpCode.Data.EDMDesigner.Core.ObjectModelConverters
{ {
if (!table.IsSelected) if (!table.IsSelected)
continue; continue;
EntityType entityType = CreateSSDLEntityType(table); EntityType entityType = CreateSSDLEntityType(table);
ssdlContainer.EntityTypes.Add(entityType); ssdlContainer.EntityTypes.Add(entityType);
@ -79,7 +79,10 @@ namespace ICSharpCode.Data.EDMDesigner.Core.ObjectModelConverters
}; };
if (table is IView) if (table is IView)
{
entityType.StoreType = StoreType.Views; entityType.StoreType = StoreType.Views;
entityType.DefiningQuery = (table as IView).DefiningQuery;
}
else else
entityType.StoreType = StoreType.Tables; entityType.StoreType = StoreType.Tables;
@ -175,7 +178,7 @@ namespace ICSharpCode.Data.EDMDesigner.Core.ObjectModelConverters
{ {
Name = constraint.FKTableName, Name = constraint.FKTableName,
Cardinality = (Cardinality)constraint.FKCardinality Cardinality = (Cardinality)constraint.FKCardinality
}; };
Property role2Property = CreateSSDLProperty(constraint.FKColumn, CreateSSDLEntityType(constraint.FKTable)); Property role2Property = CreateSSDLProperty(constraint.FKColumn, CreateSSDLEntityType(constraint.FKTable));
role2.Property = role2Property; role2.Property = role2Property;

Loading…
Cancel
Save