/// <summary> /// Construtor usado na deserialização dos dados. /// </summary> /// <param name="info"></param> /// <param name="context"></param> private QueryInfo(SerializationInfo info, StreamingContext context) { _id = info.GetInt32("Id"); var methodText = info.GetString("Method"); Method = (QueryMethod)Enum.Parse(typeof(QueryMethod), methodText); _projection = (Projection)info.GetValue("Projection", typeof(Projection)); _entities = (EntityInfo[])info.GetValue("Entities", typeof(EntityInfo[])); _executePredicate = (QueryExecutePredicate)info.GetValue("ExecutePredicate", typeof(QueryExecutePredicate)); _groupby = (GroupBy)info.GetValue("GroupBy", typeof(GroupBy)); _having = (ConditionalContainer)info.GetValue("Having", typeof(ConditionalContainer)); _sort = (Sort)info.GetValue("Sort", typeof(Sort)); _whereClause = (ConditionalContainer)info.GetValue("WhereClause", typeof(ConditionalContainer)); _takeParameters = (TakeParameters)info.GetValue("TakeParameters", typeof(TakeParameters)); _parameters = (QueryParameterCollection)info.GetValue("Parameters", typeof(QueryParameterCollection)); _nestedQueries = (QueryInfo[])info.GetValue("NestedQueries", typeof(QueryInfo[])); _unions = (UnionInfoCollection)info.GetValue("Unions", typeof(UnionInfoCollection)); _storedProcedureName = (StoredProcedureName)info.GetValue("StoredProcedureName", typeof(StoredProcedureName)); _storedProcedureProvider = info.GetString("StoredProcedureProvider"); _ignoreRegisterUserInfo = info.GetBoolean("IgnoreRegisterUserInfo"); _isolationLevel = (System.Transactions.IsolationLevel)info.GetInt16("IsolationLevel"); _commandTimeout = info.GetInt32("CommandTimeout"); _providerName = info.GetString("ProviderName"); _ignoreTypeSchema = info.GetBoolean("IgnoreTypeSchema"); }
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); } }