Status Tag is an ascii whose original value may be P, X, M.
The object it will go to is:
public class objProfileMisMatchCount
{
public int PossibleMatchId { get; set; }
public int ImportedProfileId { get; set; }
public string ImportedBarcode { get; set; }
public string BatchNo { get; set; }
public DateTime? DateImported { get; set; }
public string MatchedBarcode { get; set; }
public int DataProfileId { get; set; }
public int MismatchCount { get; set; }
public char Status { get; set; }
public int? MID { get; set; }
}
Code is:
List<objProfileMisMatchCount> matchList = new List<objProfileMisMatchCount>();
matchList =
(from m in xeItemRoot.Descendants("objProfileMisMatchCount")
join p1 in dc.Profiles on (int)m.Element("ImportedProfileId") equals p1.ProfileId
join p2 in dc.Profiles on (int)m.Element("DataProfileId") equals p2.ProfileId
select new objProfileMisMatchCount
{
PossibleMatchId = (int)m.Element("PossibleMatchId"),
ImportedProfileId = (int)m.Element("ImportedProfileId"),
DataProfileId = (int)m.Element("DataProfileId"),
MismatchCount = (int)m.Element("MismatchCount"),
DateImported = String.IsNullOrEmpty(m.Element("DateImported").Value) ? (DateTime?)null : Convert.ToDateTime(m.Element("DateImported").Value), Status = Convert.ToChar(m.Element("Status").Value),
MID = String.IsNullOrEmpty(m.Element("MID").Value) ? (int?)null : Convert.ToInt32(m.Element("MID").Value),
ImportedBarcode = p1.BarcodeNo,
MatchedBarcode = p2.BarcodeNo
}).ToList<objProfileMisMatchCount>();
Any ideas how I can convert the byte 80 to its ascii P?
Member
48 Points
291 Posts
Load XElement to a character and integer
Jul 29, 2015 08:06 PM|tinac99|LINK
Hi,
I'm trying to load an XML column into an object. The generated XML from the XML column is as follows:
<Results>
<Statistics />
<Items>
<objProfileMisMatchCount xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<PossibleMatchId>2198</PossibleMatchId>
<ImportedProfileId>304</ImportedProfileId>
<DateImported xsi:nil="true" />
<DataProfileId>306</DataProfileId>
<MismatchCount>19</MismatchCount>
<Status>80</Status>
<MID xsi:nil="true" />
</objProfileMisMatchCount>
<objProfileMisMatchCount xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<PossibleMatchId>2208</PossibleMatchId>
<ImportedProfileId>304</ImportedProfileId>
<DateImported xsi:nil="true" />
<DataProfileId>3003</DataProfileId>
<MismatchCount>16</MismatchCount>
<Status>80</Status>
<MID xsi:nil="true" />
</objProfileMisMatchCount>
</Items>
</Results>
Status Tag is an ascii whose original value may be P, X, M.
The object it will go to is:
public class objProfileMisMatchCount
{
public int PossibleMatchId { get; set; }
public int ImportedProfileId { get; set; }
public string ImportedBarcode { get; set; }
public string BatchNo { get; set; }
public DateTime? DateImported { get; set; }
public string MatchedBarcode { get; set; }
public int DataProfileId { get; set; }
public int MismatchCount { get; set; }
public char Status { get; set; }
public int? MID { get; set; }
}
Code is:
List<objProfileMisMatchCount> matchList = new List<objProfileMisMatchCount>();
matchList =
(from m in xeItemRoot.Descendants("objProfileMisMatchCount")
join p1 in dc.Profiles on (int)m.Element("ImportedProfileId") equals p1.ProfileId
join p2 in dc.Profiles on (int)m.Element("DataProfileId") equals p2.ProfileId
select new objProfileMisMatchCount
{
PossibleMatchId = (int)m.Element("PossibleMatchId"),
ImportedProfileId = (int)m.Element("ImportedProfileId"),
DataProfileId = (int)m.Element("DataProfileId"),
MismatchCount = (int)m.Element("MismatchCount"),
DateImported = String.IsNullOrEmpty(m.Element("DateImported").Value) ? (DateTime?)null : Convert.ToDateTime(m.Element("DateImported").Value),
Status = Convert.ToChar(m.Element("Status").Value),
MID = String.IsNullOrEmpty(m.Element("MID").Value) ? (int?)null : Convert.ToInt32(m.Element("MID").Value),
ImportedBarcode = p1.BarcodeNo,
MatchedBarcode = p2.BarcodeNo
}).ToList<objProfileMisMatchCount>();
Any ideas how I can convert the byte 80 to its ascii P?
Thanks,
tinac99
Star
9859 Points
974 Posts
Re: Load XElement to a character and integer
Jul 30, 2015 10:02 PM|Li Wang|LINK
Hi tinac99,
Thank you for your post.
According to your code, m.Element("Status").Value returns "80" as type of string. So you must convert value to int first. Try below code.
Best Regards,
Wang Li