void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { var attribute = reader.GetAttribute("Id"); int.TryParse(attribute, out _id); attribute = reader.GetAttribute("Method"); if (!string.IsNullOrEmpty(attribute)) { Enum.TryParse <QueryMethod>(attribute, out _method); } attribute = reader.GetAttribute("IsSelectDistinct"); bool.TryParse(attribute, out _isSelectDistinct); attribute = reader.GetAttribute("IgnoreRegisterUserInfo"); bool.TryParse(attribute, out _ignoreRegisterUserInfo); attribute = reader.GetAttribute("IsolationLevel"); if (!Enum.TryParse <System.Transactions.IsolationLevel>(attribute, out _isolationLevel)) { _isolationLevel = System.Transactions.IsolationLevel.Unspecified; } attribute = reader.GetAttribute("CommandTimeout"); if (!int.TryParse(attribute, out _commandTimeout)) { _commandTimeout = 30; } _providerName = reader.GetAttribute("ProviderName"); _storedProcedureProvider = reader.GetAttribute("StoredProcedureProvider"); attribute = reader.GetAttribute("IgnoreTypeSchema"); bool.TryParse(attribute, out _ignoreTypeSchema); reader.ReadStartElement(); _projection = ReadItem <Projection>(reader, "Projection"); _executePredicate = ReadItem <QueryExecutePredicate>(reader, "ExecutePredicate"); var entitiesQueue = new Queue <EntityInfo>(); if (!reader.IsEmptyElement && reader.LocalName == "Entities") { reader.ReadStartElement("Entities", Namespaces.Query); while (reader.NodeType != System.Xml.XmlNodeType.EndElement) { var join = new EntityInfo(); ((System.Xml.Serialization.IXmlSerializable)join).ReadXml(reader); entitiesQueue.Enqueue(join); } reader.ReadEndElement(); } else { reader.Skip(); } _entities = entitiesQueue.ToArray(); var joinsQueue = new Queue <JoinInfo>(); if (!reader.IsEmptyElement && reader.LocalName == "Joins") { reader.ReadStartElement("Joins", Namespaces.Query); while (reader.NodeType != System.Xml.XmlNodeType.EndElement) { var join = new JoinInfo(); ((System.Xml.Serialization.IXmlSerializable)join).ReadXml(reader); joinsQueue.Enqueue(join); } reader.ReadEndElement(); } else { reader.Skip(); } _joins = joinsQueue.ToArray(); _whereClause = ReadItem <ConditionalContainer>(reader, "Where"); _sort = ReadItem <Sort>(reader, "Sort"); _groupby = ReadItem <GroupBy>(reader, "GroupBy"); _having = ReadItem <ConditionalContainer>(reader, "Having"); _takeParameters = ReadItem <TakeParameters>(reader, "TakeParameters"); var nestedQueries = new List <QueryInfo>(); if (!reader.IsEmptyElement && reader.LocalName == "NestedQueries") { reader.ReadStartElement("NestedQueries", Namespaces.Query); while (reader.NodeType != System.Xml.XmlNodeType.EndElement) { var queryInfo = new QueryInfo(); ((System.Xml.Serialization.IXmlSerializable)queryInfo).ReadXml(reader); nestedQueries.Add(queryInfo); } reader.ReadEndElement(); } else { reader.Skip(); } _nestedQueries = nestedQueries.ToArray(); _parameters = new QueryParameterCollection(); if (!reader.IsEmptyElement && reader.LocalName == "Parameters") { reader.ReadStartElement("Parameters", Namespaces.Query); while (reader.NodeType != System.Xml.XmlNodeType.EndElement) { var parameter = new QueryParameter(); ((System.Xml.Serialization.IXmlSerializable)parameter).ReadXml(reader); _parameters.Add(parameter); } reader.ReadEndElement(); } else { reader.Skip(); } _storedProcedureName = ReadItem <StoredProcedureName>(reader, "StoredProcedureName"); _unions = new UnionInfoCollection(); if (!reader.IsEmptyElement && reader.LocalName == "Unions") { reader.ReadStartElement("Unions", Namespaces.Query); while (reader.NodeType != System.Xml.XmlNodeType.EndElement) { var union = new UnionInfo(); ((System.Xml.Serialization.IXmlSerializable)union).ReadXml(reader); _unions.Add(union); } reader.ReadEndElement(); } else { reader.Skip(); } reader.ReadEndElement(); }
/// <summary> /// Desserializa o objeto. /// </summary> /// <param name="reader"></param> void ICompactSerializable.Deserialize(Colosoft.Serialization.IO.CompactReader reader) { _id = reader.ReadInt32(); _isSelectDistinct = reader.ReadBoolean(); _ignoreRegisterUserInfo = reader.ReadBoolean(); try { Enum.TryParse <QueryMethod>(reader.ReadString(), out _method); } catch (OutOfMemoryException) { throw; } _isolationLevel = (System.Transactions.IsolationLevel)reader.ReadInt16(); _commandTimeout = reader.ReadInt32(); _providerName = reader.ReadString(); _ignoreTypeSchema = reader.ReadBoolean(); if (reader.ReadBoolean()) { _storedProcedureProvider = reader.ReadString(); } if (reader.ReadBoolean()) { _projection = new Projection(); ((ICompactSerializable)_projection).Deserialize(reader); } if (reader.ReadBoolean()) { _executePredicate = new QueryExecutePredicate(); ((ICompactSerializable)_executePredicate).Deserialize(reader); } var entitiesQueue = new Queue <EntityInfo>(); while (reader.ReadBoolean()) { var entity = new EntityInfo(); ((ICompactSerializable)entity).Deserialize(reader); entitiesQueue.Enqueue(entity); } _entities = entitiesQueue.ToArray(); var joinQueue = new Queue <JoinInfo>(); while (reader.ReadBoolean()) { var join = new JoinInfo(); ((ICompactSerializable)join).Deserialize(reader); joinQueue.Enqueue(join); } _joins = joinQueue.ToArray(); if (reader.ReadBoolean()) { _whereClause = new ConditionalContainer(); ((ICompactSerializable)_whereClause).Deserialize(reader); } if (reader.ReadBoolean()) { _sort = new Sort(); ((ICompactSerializable)_sort).Deserialize(reader); } if (reader.ReadBoolean()) { _groupby = new GroupBy(); ((ICompactSerializable)_groupby).Deserialize(reader); } if (reader.ReadBoolean()) { _having = new ConditionalContainer(); ((ICompactSerializable)_having).Deserialize(reader); } if (reader.ReadBoolean()) { _takeParameters = new TakeParameters(); ((ICompactSerializable)_takeParameters).Deserialize(reader); } var nestedQueries = new List <QueryInfo>(); while (reader.ReadBoolean()) { var nestedQuery = new QueryInfo(); ((ICompactSerializable)nestedQuery).Deserialize(reader); nestedQueries.Add(nestedQuery); } _nestedQueries = nestedQueries.ToArray(); if (_parameters == null) { _parameters = new QueryParameterCollection(); } while (reader.ReadBoolean()) { var parameter = new QueryParameter(); parameter.Deserialize(reader); _parameters.Add(parameter); } if (reader.ReadBoolean()) { _storedProcedureName = new StoredProcedureName(); ((ICompactSerializable)_storedProcedureName).Deserialize(reader); } if (_unions == null) { _unions = new UnionInfoCollection(); } while (reader.ReadBoolean()) { var union = new UnionInfo(); union.Deserialize(reader); _unions.Add(union); } }