Class AmlSqlWriter
Generates a SQL statement for querying the Aras database directly from an AML query
Inheritance
Inherited Members
Namespace: Innovator.Client
Assembly: Innovator.Client.dll
Syntax
public class AmlSqlWriter : XmlWriter, IDisposable
Examples
var item = ElementFactory.Local.FromXml(@"<Item type='Part' action='get' queryType='Latest' queryDate='2017-05-11T17:37:00'>
<is_active_rev>1</is_active_rev>
<keyed_name condition='like'>999-*</keyed_name>
<owned_by_id><Item type='Identity' action='get'><keyed_name condition='like'>*super*</keyed_name></Item></owned_by_id>
</Item>").AssertItem();
var writer = new AmlSqlWriter(new ConnectedAmlSqlWriterSettings(new TestConnection()) { PermissionOption = AmlSqlPermissionOption.LegacyFunction });
item.ToAml(writer);
writer.Flush();
Afterwards, ToString() should return something like
select [Part].*
from innovator.[Part]
left join innovator.[Identity]
on [Identity].id = [Part].owned_by_id
where [Part].is_active_rev = 1
and [Part].keyed_name like N'999-%'
and ([Identity].keyed_name like N'%super%' and ( SELECT p FROM innovator.[GetDiscoverPermissions] ('can_get', [Identity].permission_id, [Identity].created_by_id, [Identity].managed_by_id, [Identity].owned_by_id, [Identity].team_id, 'F13AF7BC3D7A4084AF67AB7BF938C409,A73B655731924CD0B027E4F4D5FCC0A9,1942894C56164DF4AB400434FF5EFE3B,56A96DA9E981481688563E2D14D5D878,F18B4A8C523A4B3F88CFFEE3BC68F5D4,2618D6F5A90949BAA7E920D1B04C7EE1,43CC1A53BECA4364A22C136E98E185C7,5A8E8A27AA5A47238BD96AC60A6562F3,5E47C25D3FE6464688442ABE64478537,08C52237B1124FC4BB5D4E48F660C8E2,22DF5704DCA14D86B79BFDFF3CA030B9,2C5CF38CB45C4E1F848EA6DF969364EF,31387021B15E42548FC818E893A19D08,344632A16E8949CCA5CAD0A013D50655,3A0D61E9629141C8934B948C596B2E42,3A976285BB9A4D05AE1878004A33D440,484451EB7B524ECD92FFA372A4675E38,4CAAF215654F43098B415EC0EAB1829A,4CD258EF03834E7FAC9CD76876777EBC,5E12CD824411477AA56D9F539FA295EB,600B965EA3DB41D0B7F9D9D7BDD923EC,62E1A4258C764C5E814DDA3B4209A34F,66022731E81D4040A155F13CD083826A,66F68F2DC7D3410699EA302411608618,685069C4626B406BA5EEFBD87CCABBAC,7C63ED1CFD0A4E0DAAD27AAB0C90A58D,7F50E4A530A84C22935ED7E2231198E1,82F4AA3DD22648288D63938D648CD814,84D2CEC2D1E247DC9D2D28B78D1DF591,A11E92826CA44BEEA4A84E494D13F0B8,A4AFDB4EBD2A4130A4D0616E2E63F552,AD55DC9C04274E67A2C4C45AADC9D059,B3DC39013C13458F9D3A479046B25266,BFE82C27CAAB4667B51EEC64D818BEC8,C02E1CEE4C2B492496EAEC1C19F814B0,C3DB96EFB5EC47AE816CE16AE3E79959,C5C35BB6D73145DB8C88084BEA96BB1D,C6D220539A8D4458B27CA579B637967F,C8FE09099D8D4C25BED39BBFE3BF0476,D78B07BAF283495E9540115C00AD9CED,DE6E87399974415F948D4468C07C5134,E42675D6FC354C86880230D5DA79E4CD,FFB8C4C174054BD3AA17A00023AD49BC,25EAA8CA05254E1DB191F984D994751D,5D58B17DB5094950B93AE13202E46C5E,6A2F0C9740B74625B744E5FCE43879F6,7FA8E5852B7F4FE1817C24A11798A784,B32BD81D1AD04207BF1E61E39A4E0E13,FA8573065D534FBB8DA1E40C14FA54EF,0CDBE4C0F8A045159339D1C8BE8665FA,31E5C20B933D433CA8F509F7AED9E68A,5E7DC598214E4BBAA09CDB91D644FABD,78A5819F71E2414EB48C5984AB005ABB,988240C797D548A79A78B1AD4CDED7B3,3FCE6B2163FC4F5983BF00A13E6B047E', null, '2D246C5838644C1C8FD34F8D2796E327', '8FE5430B42014D94AE83246F299D9CC4', '9200A800443E4A5AAA80D0BCE5760307', '538B300BB2A347F396C436E9EEE1976C' ) ) > 0)
and ( SELECT p FROM innovator.[GetDiscoverPermissions] ('can_get', [Part].permission_id, [Part].created_by_id, [Part].managed_by_id, [Part].owned_by_id, [Part].team_id, 'F13AF7BC3D7A4084AF67AB7BF938C409,A73B655731924CD0B027E4F4D5FCC0A9,1942894C56164DF4AB400434FF5EFE3B,56A96DA9E981481688563E2D14D5D878,F18B4A8C523A4B3F88CFFEE3BC68F5D4,2618D6F5A90949BAA7E920D1B04C7EE1,43CC1A53BECA4364A22C136E98E185C7,5A8E8A27AA5A47238BD96AC60A6562F3,5E47C25D3FE6464688442ABE64478537,08C52237B1124FC4BB5D4E48F660C8E2,22DF5704DCA14D86B79BFDFF3CA030B9,2C5CF38CB45C4E1F848EA6DF969364EF,31387021B15E42548FC818E893A19D08,344632A16E8949CCA5CAD0A013D50655,3A0D61E9629141C8934B948C596B2E42,3A976285BB9A4D05AE1878004A33D440,484451EB7B524ECD92FFA372A4675E38,4CAAF215654F43098B415EC0EAB1829A,4CD258EF03834E7FAC9CD76876777EBC,5E12CD824411477AA56D9F539FA295EB,600B965EA3DB41D0B7F9D9D7BDD923EC,62E1A4258C764C5E814DDA3B4209A34F,66022731E81D4040A155F13CD083826A,66F68F2DC7D3410699EA302411608618,685069C4626B406BA5EEFBD87CCABBAC,7C63ED1CFD0A4E0DAAD27AAB0C90A58D,7F50E4A530A84C22935ED7E2231198E1,82F4AA3DD22648288D63938D648CD814,84D2CEC2D1E247DC9D2D28B78D1DF591,A11E92826CA44BEEA4A84E494D13F0B8,A4AFDB4EBD2A4130A4D0616E2E63F552,AD55DC9C04274E67A2C4C45AADC9D059,B3DC39013C13458F9D3A479046B25266,BFE82C27CAAB4667B51EEC64D818BEC8,C02E1CEE4C2B492496EAEC1C19F814B0,C3DB96EFB5EC47AE816CE16AE3E79959,C5C35BB6D73145DB8C88084BEA96BB1D,C6D220539A8D4458B27CA579B637967F,C8FE09099D8D4C25BED39BBFE3BF0476,D78B07BAF283495E9540115C00AD9CED,DE6E87399974415F948D4468C07C5134,E42675D6FC354C86880230D5DA79E4CD,FFB8C4C174054BD3AA17A00023AD49BC,25EAA8CA05254E1DB191F984D994751D,5D58B17DB5094950B93AE13202E46C5E,6A2F0C9740B74625B744E5FCE43879F6,7FA8E5852B7F4FE1817C24A11798A784,B32BD81D1AD04207BF1E61E39A4E0E13,FA8573065D534FBB8DA1E40C14FA54EF,0CDBE4C0F8A045159339D1C8BE8665FA,31E5C20B933D433CA8F509F7AED9E68A,5E7DC598214E4BBAA09CDB91D644FABD,78A5819F71E2414EB48C5984AB005ABB,988240C797D548A79A78B1AD4CDED7B3,3FCE6B2163FC4F5983BF00A13E6B047E', null, '2D246C5838644C1C8FD34F8D2796E327', '8FE5430B42014D94AE83246F299D9CC4', '9200A800443E4A5AAA80D0BCE5760307', '538B300BB2A347F396C436E9EEE1976C' ) ) > 0
order by [Part].id
Constructors
| Improve this Doc View SourceAmlSqlWriter(IAmlSqlWriterSettings)
Creates an System.Xml.XmlWriter that will output a SQL statement from an AML query
Declaration
public AmlSqlWriter(IAmlSqlWriterSettings settings)
Parameters
Type | Name | Description |
---|---|---|
IAmlSqlWriterSettings | settings |
AmlSqlWriter(TextWriter, IAmlSqlWriterSettings)
Creates an System.Xml.XmlWriter that will output a SQL statement from an AML query
Declaration
public AmlSqlWriter(TextWriter writer, IAmlSqlWriterSettings settings)
Parameters
Type | Name | Description |
---|---|---|
System.IO.TextWriter | writer | |
IAmlSqlWriterSettings | settings |
Properties
| Improve this Doc View SourceWriteState
Gets the state of the writer.
Declaration
public override WriteState WriteState { get; }
Property Value
Type | Description |
---|---|
System.Xml.WriteState | One of the WriteState values. |
Overrides
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | An System.Xml.XmlWriter method was called before a previous asynchronous operation finished. In this case, System.InvalidOperationException is thrown with the message “An asynchronous operation is already in progress.” |
Methods
| Improve this Doc View SourceDispose(Boolean)
Releases the unmanaged resources used by the System.Xml.XmlWriter and optionally releases the managed resources.
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing | true to release both managed and unmanaged resources; false to release only unmanaged resources. |
Overrides
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | An System.Xml.XmlWriter method was called before a previous asynchronous operation finished. In this case, System.InvalidOperationException is thrown with the message “An asynchronous operation is already in progress.” |
Flush()
Flushes whatever is in the buffer to the underlying streams and also flushes the underlying stream.
Declaration
public override void Flush()
Overrides
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | An System.Xml.XmlWriter method was called before a previous asynchronous operation finished. In this case, System.InvalidOperationException is thrown with the message “An asynchronous operation is already in progress.” |
LookupPrefix(String)
Returns the closest prefix defined in the current namespace scope for the namespace URI.
Declaration
public override string LookupPrefix(string ns)
Parameters
Type | Name | Description |
---|---|---|
System.String | ns | The namespace URI whose prefix you want to find. |
Returns
Type | Description |
---|---|
System.String | The matching prefix or null if no matching namespace URI is found in the current scope. |
Overrides
Exceptions
Type | Condition |
---|---|
System.ArgumentException |
|
System.InvalidOperationException | An System.Xml.XmlWriter method was called before a previous asynchronous operation finished. In this case, System.InvalidOperationException is thrown with the message “An asynchronous operation is already in progress.” |
ToString()
Returns the generated SQL using the RenderOption specified in the IAmlSqlWriterSettings
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | A System.String that represents this instance. |
Overrides
ToString(AmlSqlRenderOption)
Returns the generated SQL
Declaration
public string ToString(AmlSqlRenderOption renderOption)
Parameters
Type | Name | Description |
---|---|---|
AmlSqlRenderOption | renderOption | Option specifying what SQL to generate |
Returns
Type | Description |
---|---|
System.String |
ToString(TextWriter, AmlSqlRenderOption)
Returns the generated SQL
Declaration
public void ToString(TextWriter writer, AmlSqlRenderOption renderOption)
Parameters
Type | Name | Description |
---|---|---|
System.IO.TextWriter | writer | System.IO.TextWriter to write the SQL to |
AmlSqlRenderOption | renderOption | Option specifying what SQL to generate |
WriteBase64(Byte[], Int32, Int32)
Not supported
Declaration
public override void WriteBase64(byte[] buffer, int index, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | |
System.Int32 | index | |
System.Int32 | count |
Overrides
WriteCData(String)
Writes out a <![CDATA[...]]> block containing the specified text.
Declaration
public override void WriteCData(string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text to place inside the CDATA block. |
Overrides
WriteCharEntity(Char)
Forces the generation of a character entity for the specified Unicode character value.
Declaration
public override void WriteCharEntity(char ch)
Parameters
Type | Name | Description |
---|---|---|
System.Char | ch | The Unicode character for which to generate a character entity. |
Overrides
Exceptions
Type | Condition |
---|---|
System.ArgumentException | The character is in the surrogate pair character range, 0xd800 - 0xdfff. |
System.InvalidOperationException | An System.Xml.XmlWriter method was called before a previous asynchronous operation finished. In this case, System.InvalidOperationException is thrown with the message “An asynchronous operation is already in progress.” |
WriteChars(Char[], Int32, Int32)
Writes text one buffer at a time.
Declaration
public override void WriteChars(char[] buffer, int index, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Char[] | buffer | Character array containing the text to write. |
System.Int32 | index | The position in the buffer indicating the start of the text to write. |
System.Int32 | count | The number of characters to write. |
Overrides
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
System.ArgumentOutOfRangeException |
|
System.ArgumentException | The |
System.InvalidOperationException | An System.Xml.XmlWriter method was called before a previous asynchronous operation finished. In this case, System.InvalidOperationException is thrown with the message “An asynchronous operation is already in progress.” |
WriteComment(String)
Does nothing
Declaration
public override void WriteComment(string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text |
Overrides
WriteDocType(String, String, String, String)
Does nothing
Declaration
public override void WriteDocType(string name, string pubid, string sysid, string subset)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | |
System.String | pubid | |
System.String | sysid | |
System.String | subset |
Overrides
WriteEndAttribute()
Closes the previous System.Xml.XmlWriter.WriteStartAttribute(System.String, System.String) call.
Declaration
public override void WriteEndAttribute()
Overrides
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | An System.Xml.XmlWriter method was called before a previous asynchronous operation finished. In this case, System.InvalidOperationException is thrown with the message “An asynchronous operation is already in progress.” |
WriteEndDocument()
Does nothing
Declaration
public override void WriteEndDocument()
Overrides
WriteEndElement()
Closes one element and pops the corresponding namespace scope.
Declaration
public override void WriteEndElement()
Overrides
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | This results in an invalid XML document. |
System.InvalidOperationException | An System.Xml.XmlWriter method was called before a previous asynchronous operation finished. In this case, System.InvalidOperationException is thrown with the message “An asynchronous operation is already in progress.” |
WriteEntityRef(String)
Writes out an entity reference as &name;.
Declaration
public override void WriteEntityRef(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the entity reference. |
Overrides
Exceptions
Type | Condition |
---|---|
System.ArgumentException |
|
System.InvalidOperationException | An System.Xml.XmlWriter method was called before a previous asynchronous operation finished. In this case, System.InvalidOperationException is thrown with the message “An asynchronous operation is already in progress.” |
WriteFullEndElement()
Closes one element and pops the corresponding namespace scope.
Declaration
public override void WriteFullEndElement()
Overrides
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | An System.Xml.XmlWriter method was called before a previous asynchronous operation finished. In this case, System.InvalidOperationException is thrown with the message “An asynchronous operation is already in progress.” |
WriteProcessingInstruction(String, String)
Not supported
Declaration
public override void WriteProcessingInstruction(string name, string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | |
System.String | text |
Overrides
WriteRaw(Char[], Int32, Int32)
Not supported
Declaration
public override void WriteRaw(char[] buffer, int index, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Char[] | buffer | |
System.Int32 | index | |
System.Int32 | count |
Overrides
WriteRaw(String)
Not supported
Declaration
public override void WriteRaw(string data)
Parameters
Type | Name | Description |
---|---|---|
System.String | data |
Overrides
WriteStartAttribute(String, String, String)
Writes the start of an attribute with the specified prefix, local name, and namespace URI.
Declaration
public override void WriteStartAttribute(string prefix, string localName, string ns)
Parameters
Type | Name | Description |
---|---|---|
System.String | prefix | The namespace prefix of the attribute. |
System.String | localName | The local name of the attribute. |
System.String | ns | The namespace URI for the attribute. |
Overrides
Exceptions
Type | Condition |
---|---|
System.Text.EncoderFallbackException | There is a character in the buffer that is a valid XML character but is not valid for the output encoding. For example, if the output encoding is ASCII, you should only use characters from the range of 0 to 127 for element and attribute names. The invalid character might be in the argument of this method or in an argument of previous methods that were writing to the buffer. Such characters are escaped by character entity references when possible (for example, in text nodes or attribute values). However, the character entity reference is not allowed in element and attribute names, comments, processing instructions, or CDATA sections. |
System.InvalidOperationException | An System.Xml.XmlWriter method was called before a previous asynchronous operation finished. In this case, System.InvalidOperationException is thrown with the message “An asynchronous operation is already in progress.” |
WriteStartDocument()
Does nothing
Declaration
public override void WriteStartDocument()
Overrides
WriteStartDocument(Boolean)
Does nothing
Declaration
public override void WriteStartDocument(bool standalone)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | standalone |
Overrides
WriteStartElement(String, String, String)
Writes the specified start tag and associates it with the given namespace and prefix.
Declaration
public override void WriteStartElement(string prefix, string localName, string ns)
Parameters
Type | Name | Description |
---|---|---|
System.String | prefix | The namespace prefix of the element. |
System.String | localName | The local name of the element. |
System.String | ns | The namespace URI to associate with the element. |
Overrides
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | The writer is closed. |
System.Text.EncoderFallbackException | There is a character in the buffer that is a valid XML character but is not valid for the output encoding. For example, if the output encoding is ASCII, you should only use characters from the range of 0 to 127 for element and attribute names. The invalid character might be in the argument of this method or in an argument of previous methods that were writing to the buffer. Such characters are escaped by character entity references when possible (for example, in text nodes or attribute values). However, the character entity reference is not allowed in element and attribute names, comments, processing instructions, or CDATA sections. |
System.InvalidOperationException | An System.Xml.XmlWriter method was called before a previous asynchronous operation finished. In this case, System.InvalidOperationException is thrown with the message “An asynchronous operation is already in progress.” |
WriteString(String)
Writes the given text content.
Declaration
public override void WriteString(string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text to write. |
Overrides
Exceptions
Type | Condition |
---|---|
System.ArgumentException | The text string contains an invalid surrogate pair. |
System.InvalidOperationException | An System.Xml.XmlWriter method was called before a previous asynchronous operation finished. In this case, System.InvalidOperationException is thrown with the message “An asynchronous operation is already in progress.” |
WriteSurrogateCharEntity(Char, Char)
Generates and writes the surrogate character entity for the surrogate character pair.
Declaration
public override void WriteSurrogateCharEntity(char lowChar, char highChar)
Parameters
Type | Name | Description |
---|---|---|
System.Char | lowChar | The low surrogate. This must be a value between 0xDC00 and 0xDFFF. |
System.Char | highChar | The high surrogate. This must be a value between 0xD800 and 0xDBFF. |
Overrides
Exceptions
Type | Condition |
---|---|
System.ArgumentException | An invalid surrogate character pair was passed. |
System.InvalidOperationException | An System.Xml.XmlWriter method was called before a previous asynchronous operation finished. In this case, System.InvalidOperationException is thrown with the message “An asynchronous operation is already in progress.” |
WriteWhitespace(String)
Writes out the given white space.
Declaration
public override void WriteWhitespace(string ws)
Parameters
Type | Name | Description |
---|---|---|
System.String | ws | The string of white space characters. |
Overrides
Exceptions
Type | Condition |
---|---|
System.ArgumentException | The string contains non-white space characters. |
System.InvalidOperationException | An System.Xml.XmlWriter method was called before a previous asynchronous operation finished. In this case, System.InvalidOperationException is thrown with the message “An asynchronous operation is already in progress.” |