Return List<ComplexType> from ObjectResult<ComplexType> - and will it be XML?
Tag : chash , By : semicolonth
Date : March 29 2020, 07:55 AM
should help you out As ObjectResult implements IEnumerable, you can use IEnumerable extension methods and get an array of T using:ObjectResult<ComplexType> res = ....;
ComplexType[] array = res.ToArray<ComplexType>(); // res.ToArray() is also fine because of type inference
|
List<ComplexType> : need to do a linq query on a property of the ComplexType
Tag : chash , By : Tonci Grgin
Date : March 29 2020, 07:55 AM
Hope this helps As an example, I have a type like this: , You can do some of the following Solution 1 public static double StandardDeviation(List<double> valueList)
{
double M = 0.0;
double S = 0.0;
int k = 1;
foreach (double value in valueList)
{
double tmpM = M;
M += (value - tmpM) / k;
S += (value - tmpM) * (value - M);
k++;
}
return Math.Sqrt(S / (k-2));
}
List<Double> stuffAmounts = myListOfStuff.Select(s => s.StuffAmount).ToList()
double result = StandardDeviation(stuffAmounts);
public static class MathExtensions
{
public static double StandardDeviation<T>(this List<T> list, Func<T, Double> selector) where T : class
{
var m = 0.0;
var s = 0.0;
var k = 1;
foreach (var value in list.Select(selector))
{
var tmpM = m;
m += (value - tmpM) / k;
s += (value - tmpM) * (value - m);
k++;
}
return Math.Sqrt(s / (k - 2));
}
}
var stuffs = new List<Stuff>();
var result = stuffs.StandardDeviation(x => x.StuffAmount);
|
XML schema complexType within an complexType
Tag : xml , By : Yohan Lee
Date : March 29 2020, 07:55 AM
help you fix your problem You must either (solution 1) wrap the in an or (solution 2) define the elsewhere and refer to it with an . complexType is aimed at defining a content model, for any element you want to create (and type). Solution 2 is sometimes preferable because it allows you reuse (as-is, or extend, or restrict) content models you define. Examples: <xsd:element name="interface">
<xsd:complexType>
[... definition of the complexType ...]
<xsd:complexType name="WebServiceInterface">
[... definition of the complexType ...]
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="interface" type="WebServiceInterface"/>
<xsd:complexType name="WebServiceInterface">
<xsd:sequence>
<xsd:element name="package" type="xsd:string"/>
<xsd:element name="import" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="abstract_method" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="modifier" type="xsd:string"/>
<xsd:element name="arguments">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="parameter" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="exceptions">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="exception" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="return"/>
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string"/>
</xsd:complexType>
</xsd:schema>
|
ComplexType inside ComplexType
Tag : xml , By : James Lupiani
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , You can have a xs:complexType inside a xs:complexType, but not directly. Based on your XML, you want to define an element, glowne_role, to be of complex type consisting of a sequence of aktor elements, each of which then in turn can also be of complex type. Note that to allow text to precede or follow your komentarz you can set mixed="true" on the parent xs:complexType. Altogether, then, this XSD will successfully validate your XML: <?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="komentarz" type="xs:string"/>
<xs:element name="glowne_role">
<xs:complexType>
<xs:sequence>
<xs:element name="aktor" minOccurs="1" maxOccurs="3">
<xs:complexType mixed="true">
<xs:sequence>
<xs:element ref="komentarz" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
|
XML Schema extension where both base complextype and extension complextype use same attribute
Tag : xml , By : ChaseVoid
Date : March 29 2020, 07:55 AM
wish help you to fix your issue I am trying to understand why some XSD tools (Oxygen) accept the following definition but others (notably XMLspy) do not: , Saxon reports: Error on line 5 of test.xsd:
Attribute @property appears more than once in attribute group
Schema processing failed: The schema is invalid
|