Beispiel #1
0
 protected IPersistenceProvider GetProvider(Mapping mapping)
 {
     SqlMapperProvider engine = new SqlMapperProvider();
     engine.Mapping = mapping;
     engine.RegisterMetaData(Evaluant.Uss.MetaData.MetaDataFactory.FromAssembly(Assembly.GetExecutingAssembly(), Namespace));
     engine.ConnectionString = ConfigurationManager.ConnectionStrings["SqlMapper.SqlServer"].ConnectionString;
     return engine;
 }
Beispiel #2
0
		/// <summary>
		/// Saves the given model root to the given file, with default encoding (UTF-8), and optional properties with default value will not
		/// be written out.
		/// </summary>
		/// <param name="serializationResult">Stores serialization result from the save operation.</param>
		/// <param name="modelRoot">Mapping instance to be saved.</param>
		/// <param name="fileName">Name of the file in which the Mapping instance will be saved.</param>
		public virtual void SaveModel(DslModeling::SerializationResult serializationResult, Mapping modelRoot, string fileName)
		{
			this.SaveModel(serializationResult, modelRoot, fileName, global::System.Text.Encoding.UTF8, false);
		}
Beispiel #3
0
 public SqlExpressions.UpdateStatement Update(Mapping.Entity reference)
 {
     throw new NotImplementedException();
 }
Beispiel #4
0
 public void Create(Mapping.Entity entity, SqlExpressions.InsertStatement insert)
 {
     throw new NotImplementedException();
 }
Beispiel #5
0
 public SqlExpressions.InsertStatement Create(Mapping.Entity reference)
 {
     throw new NotImplementedException();
 }
Beispiel #6
0
		/// <summary>
		/// This method deserializes all child model elements.
		/// </summary>
		/// <remarks>
		/// The caller will position the reader at the open tag of the first child XML element to deserialized.
		/// This method will read as many child elements as it can. It returns under three circumstances:
		/// 1) When an unknown child XML element is encountered. In this case, this method will position the reader at the 
		///    open tag of the unknown element. This implies that if the first child XML element is unknown, this method 
		///    should return immediately and do nothing.
		/// 2) When all child XML elemnets are read. In this case, the reader will be positioned at the end tag of the parent element.
		/// 3) EOF.
		/// </remarks>
		/// <param name="serializationContext">Serialization context.</param>
		/// <param name="reader">XmlReader to read serialized data from.</param>
		/// <param name="element">In-memory Mapping instance that will get the deserialized data.</param>
		private static void ReadChildElements(DslModeling::SerializationContext serializationContext, Mapping element, global::System.Xml.XmlReader reader)
		{
			if (!serializationContext.Result.Failed && !reader.EOF && reader.NodeType == global::System.Xml.XmlNodeType.Element)
			{
				if (string.Compare(reader.LocalName, "entities", global::System.StringComparison.CurrentCulture) == 0)
				{
					if (reader.IsEmptyElement)
					{	// No instance of this relationship, just skip
						DslModeling::SerializationUtilities.Skip(reader);
					}
					else
					{
						DslModeling::SerializationUtilities.SkipToFirstChild(reader);  // Skip the open tag of <entities>
						ReadMappingHasEntitiesInstances(serializationContext, element, reader);
						DslModeling::SerializationUtilities.Skip(reader);  // Skip the close tag of </entities>
					}
				}
			}
		}
Beispiel #7
0
		/// <summary>
		/// Saves the given diagram to the given file, with default encoding (UTF-8).
		/// </summary>
		/// <param name="serializationResult">Stores serialization result from the save operation.</param>
		/// <param name="modelRoot">Mapping instance to be saved.</param>
		/// <param name="modelFileName">Name of the file in which the CanonicalSampleRoot instance will be saved.</param>
		/// <param name="diagram">SqlMapperMappingDiagram to be saved.</param>
		/// <param name="diagramFileName">Name of the file in which the diagram will be saved.</param>
		/// <param name="writeOptionalPropertiesWithDefaultValue">Whether optional properties with default value will be saved.</param>
		public virtual void SaveModelAndDiagram(DslModeling::SerializationResult serializationResult, Mapping modelRoot, string modelFileName, SqlMapperMappingDiagram diagram, string diagramFileName, bool writeOptionalPropertiesWithDefaultValue)
		{
			this.SaveModelAndDiagram(serializationResult, modelRoot, modelFileName, diagram, diagramFileName, global::System.Text.Encoding.UTF8, writeOptionalPropertiesWithDefaultValue);
		}
Beispiel #8
0
		/// <summary>
		/// Helper method to create and initialize a new Mapping.
		/// </summary>
		internal protected virtual Mapping CreateModelHelper(DslModeling::Partition modelPartition)
		{
			Mapping model = new Mapping(modelPartition);
			return model;
		}
Beispiel #9
0
 public EraMapper(IDriver driver, Mapping.Mapping mapping)
     : this(driver)
 {
     this.driver = driver;
     this.Mapping = mapping;
 }
Beispiel #10
0
 public SqlExpressions.IDbStatement Create(Mapping.Reference reference, SqlExpressions.ValuedParameter childId)
 {
     throw new NotImplementedException();
 }
Beispiel #11
0
		/// <summary>
		/// Constructor
		/// Creates a MappingHasEntities link in the same Partition as the given Mapping
		/// </summary>
		/// <param name="source">Mapping to use as the source of the relationship.</param>
		/// <param name="target">Entity to use as the target of the relationship.</param>
		public MappingHasEntities(Mapping source, Entity target)
			: base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[]{new DslModeling::RoleAssignment(MappingHasEntities.MappingDomainRoleId, source), new DslModeling::RoleAssignment(MappingHasEntities.EntityDomainRoleId, target)}, null)
		{
		}
Beispiel #12
0
		public static DslModeling::LinkedElementCollection<Entity> GetEntities(Mapping element)
		{
			return GetRoleCollection<DslModeling::LinkedElementCollection<Entity>, Entity>(element, MappingDomainRoleId);
		}
Beispiel #13
0
		public static void SetMapping(Entity element, Mapping newMapping)
		{
			DslModeling::DomainRoleInfo.SetLinkedElement(element, EntityDomainRoleId, newMapping);
		}
Beispiel #14
0
		private static void WriteChildElements(DslModeling::SerializationContext serializationContext, Mapping element, global::System.Xml.XmlWriter writer)
		{
			// MappingHasEntities
			global::System.Collections.ObjectModel.ReadOnlyCollection<MappingHasEntities> allMappingHasEntitiesInstances = MappingHasEntities.GetLinksToEntities(element);
			if (!serializationContext.Result.Failed && allMappingHasEntitiesInstances.Count > 0)
			{
				writer.WriteStartElement("entities");
				foreach (MappingHasEntities eachMappingHasEntitiesInstance in allMappingHasEntitiesInstances)
				{
					if (serializationContext.Result.Failed)
						break;
	
					DslModeling::DomainClassXmlSerializer relSerializer = serializationContext.Directory.GetSerializer(eachMappingHasEntitiesInstance.GetDomainClass().Id);
					global::System.Diagnostics.Debug.Assert(relSerializer != null, "Cannot find serializer for " + eachMappingHasEntitiesInstance.GetDomainClass().Name + "!");
					relSerializer.Write(serializationContext, eachMappingHasEntitiesInstance, writer);
				}
				writer.WriteEndElement();
			}
	
		}
Beispiel #15
0
		/// <summary>
		/// Reads all instances of relationship MappingHasEntities.
		/// </summary>
		/// <remarks>
		/// The caller will position the reader at the open tag of the first XML element inside the relationship tag, so it can be
		/// either the first instance, or a bogus tag. This method will deserialize all instances and ignore all bogus tags. When the
		/// method returns, the reader will be positioned at the end tag of the relationship (or EOF if somehow that happens).
		/// </remarks>
		/// <param name="serializationContext">Serialization context.</param>
		/// <param name="element">In-memory Mapping instance that will get the deserialized data.</param>
		/// <param name="reader">XmlReader to read serialized data from.</param>
		private static void ReadMappingHasEntitiesInstances(DslModeling::SerializationContext serializationContext, Mapping element, global::System.Xml.XmlReader reader)
		{
			while (!serializationContext.Result.Failed && !reader.EOF && reader.NodeType == global::System.Xml.XmlNodeType.Element)
			{
				DslModeling::DomainClassXmlSerializer newMappingHasEntitiesSerializer = serializationContext.Directory.GetSerializer(MappingHasEntities.DomainClassId);
				global::System.Diagnostics.Debug.Assert(newMappingHasEntitiesSerializer != null, "Cannot find serializer for MappingHasEntities!");
				MappingHasEntities newMappingHasEntities = newMappingHasEntitiesSerializer.TryCreateInstance (serializationContext, reader, element.Partition) as MappingHasEntities;
				if (newMappingHasEntities != null)
				{
					DslModeling::DomainRoleInfo.SetRolePlayer (newMappingHasEntities, MappingHasEntities.MappingDomainRoleId, element);
					DslModeling::DomainClassXmlSerializer targetSerializer = serializationContext.Directory.GetSerializer (newMappingHasEntities.GetDomainClass().Id);	
					global::System.Diagnostics.Debug.Assert (targetSerializer != null, "Cannot find serializer for " + newMappingHasEntities.GetDomainClass().Name + "!");
					targetSerializer.Read(serializationContext, newMappingHasEntities, reader);
				}
				else
				{	// Maybe the relationship is serialized in short-form by mistake.
					DslModeling::DomainClassXmlSerializer newEntityOfMappingHasEntitiesSerializer = serializationContext.Directory.GetSerializer(Entity.DomainClassId);
					global::System.Diagnostics.Debug.Assert(newEntityOfMappingHasEntitiesSerializer != null, "Cannot find serializer for Entity!");
					Entity newEntityOfMappingHasEntities = newEntityOfMappingHasEntitiesSerializer.TryCreateInstance(serializationContext, reader, element.Partition) as Entity;
					if (newEntityOfMappingHasEntities != null)
					{
						SqlMapperMappingSerializationBehaviorSerializationMessages.ExpectingFullFormRelationship(serializationContext, reader, typeof(MappingHasEntities));
						element.Entities.Add(newEntityOfMappingHasEntities);
						DslModeling::DomainClassXmlSerializer targetSerializer = serializationContext.Directory.GetSerializer (newEntityOfMappingHasEntities.GetDomainClass().Id);	
						global::System.Diagnostics.Debug.Assert (targetSerializer != null, "Cannot find serializer for " + newEntityOfMappingHasEntities.GetDomainClass().Name + "!");
						targetSerializer.Read(serializationContext, newEntityOfMappingHasEntities, reader);
					}
					else
					{	// Unknown element, skip.
						DslModeling::SerializationUtilities.Skip(reader);
					}
				}
			}
		}
Beispiel #16
0
		/// <summary>
		/// Saves the given model to the given file, with default encoding (UTF-8).
		/// </summary>
		/// <param name="serializationResult">Stores serialization result from the save operation.</param>
		/// <param name="modelRoot">Mapping instance to be saved.</param>
		/// <param name="fileName">Name of the file in which the Mapping instance will be saved.</param>
		/// <param name="writeOptionalPropertiesWithDefaultValue">Whether optional properties with default value will be saved.</param>
		public virtual void SaveModel(DslModeling::SerializationResult serializationResult, Mapping modelRoot, string fileName, bool writeOptionalPropertiesWithDefaultValue)
		{
			this.SaveModel(serializationResult, modelRoot, fileName, global::System.Text.Encoding.UTF8, writeOptionalPropertiesWithDefaultValue);
		}
Beispiel #17
0
		internal global::System.IO.MemoryStream InternalSaveModel(DslModeling::SerializationResult serializationResult, Mapping modelRoot, string fileName, global::System.Text.Encoding encoding, bool writeOptionalPropertiesWithDefaultValue)
		{
			#region Check Parameters
			global::System.Diagnostics.Debug.Assert(serializationResult != null);
			global::System.Diagnostics.Debug.Assert(modelRoot != null);
			global::System.Diagnostics.Debug.Assert(!serializationResult.Failed);
			#endregion
	
			serializationResult.Encoding = encoding;
	
			DslModeling::DomainXmlSerializerDirectory directory = this.GetDirectory(modelRoot.Store);
	
			
			global::System.IO.MemoryStream newFileContent = new global::System.IO.MemoryStream();
			
			DslModeling::SerializationContext serializationContext = new DslModeling::SerializationContext(directory, fileName, serializationResult);
			this.InitializeSerializationContext(modelRoot.Partition, serializationContext, false);
			// MonikerResolver shouldn't be required in Save operation, so not calling SetupMonikerResolver() here.
			serializationContext.WriteOptionalPropertiesWithDefaultValue = writeOptionalPropertiesWithDefaultValue;
			global::System.Xml.XmlWriterSettings settings = SqlMapperMappingSerializationHelper.Instance.CreateXmlWriterSettings(serializationContext, false, encoding);
			using (global::System.Xml.XmlWriter writer = global::System.Xml.XmlWriter.Create(newFileContent, settings))
			{
				this.WriteRootElement(serializationContext, modelRoot, writer);
			}
				
			return newFileContent;
		}
Beispiel #18
0
 public NLinq.Expressions.BinaryExpression On(Mapping.Reference rm)
 {
     throw new NotImplementedException();
 }
Beispiel #19
0
		/// <summary>
		/// Saves the given diagram to the given file, with default encoding (UTF-8), and optional properties with default value will not
		/// be written out.
		/// </summary>
		/// <param name="serializationResult">Stores serialization result from the save operation.</param>
		/// <param name="modelRoot">Mapping instance to be saved.</param>
		/// <param name="modelFileName">Name of the file in which the CanonicalSampleRoot instance will be saved.</param>
		/// <param name="diagram">SqlMapperMappingDiagram to be saved.</param>
		/// <param name="diagramFileName">Name of the file in which the diagram will be saved.</param>
		public virtual void SaveModelAndDiagram(DslModeling::SerializationResult serializationResult, Mapping modelRoot, string modelFileName, SqlMapperMappingDiagram diagram, string diagramFileName)
		{
			this.SaveModelAndDiagram(serializationResult, modelRoot, modelFileName, diagram, diagramFileName, global::System.Text.Encoding.UTF8, false);
		}
Beispiel #20
0
 public SqlExpressions.IAliasedExpression Join(Mapping.Reference rm, out SqlExpressions.TableAlias firstAlias)
 {
     throw new NotImplementedException();
 }
Beispiel #21
0
		public virtual void SaveModelAndDiagram(DslModeling::SerializationResult serializationResult, Mapping modelRoot, string modelFileName, SqlMapperMappingDiagram diagram, string diagramFileName, global::System.Text.Encoding encoding, bool writeOptionalPropertiesWithDefaultValue)
		{
			#region Check Parameters
			if (serializationResult == null)
				throw new global::System.ArgumentNullException("serializationResult");
			if (string.IsNullOrEmpty(modelFileName))
				throw new global::System.ArgumentNullException("modelFileName");
			if (diagram == null)
				throw new global::System.ArgumentNullException("diagram");
			if (string.IsNullOrEmpty(diagramFileName))
				throw new global::System.ArgumentNullException("diagramFileName");
			#endregion
	
			if (serializationResult.Failed)
				return;
	
			// Save the model file first
			using (global::System.IO.MemoryStream modelFileContent = this.InternalSaveModel(serializationResult, modelRoot, modelFileName, encoding, writeOptionalPropertiesWithDefaultValue))
			{
				if (serializationResult.Failed)
					return;
	
				using (global::System.IO.MemoryStream diagramFileContent = this.InternalSaveDiagram(serializationResult, diagram, diagramFileName, encoding, writeOptionalPropertiesWithDefaultValue))
				{
					if (!serializationResult.Failed)
					{
						// Only write the contents if there's no error encountered during serialization.
						if (modelFileContent != null)
						{
							using (global::System.IO.FileStream fileStream = new global::System.IO.FileStream(modelFileName, global::System.IO.FileMode.Create, global::System.IO.FileAccess.Write, global::System.IO.FileShare.None))
							{
								using (global::System.IO.BinaryWriter writer = new global::System.IO.BinaryWriter(fileStream, encoding))
								{
									writer.Write(modelFileContent.ToArray());
								}
							}
						}
						if (diagramFileContent != null)
						{
							using (global::System.IO.FileStream fileStream = new global::System.IO.FileStream(diagramFileName, global::System.IO.FileMode.Create, global::System.IO.FileAccess.Write, global::System.IO.FileShare.None))
							{
								using (global::System.IO.BinaryWriter writer = new global::System.IO.BinaryWriter(fileStream, encoding))
								{
									writer.Write(diagramFileContent.ToArray());
								}
							}
						}
					}
				}
			}
		}
Beispiel #22
0
 public SqlExpressions.IDbStatement Delete(Mapping.Reference reference)
 {
     throw new NotImplementedException();
 }