S
shapper
Hello,
I have the following query:
IQueryable<Bag> bags = (from b in context.Elements("Bags")
orderby b.Element("Updated").Value
descending
select new Bag {
Id = new Guid(b.Element("Id").Value),
Content = b.Element("Content").Value,
Created = DateTime.Parse(b.Element
("Created").Value),
Name = b.Element("Name").Value,
Open = Boolean.Parse(b.Element
("Open").Value),
Updated = DateTime.Parse(b.Element
("Updated").Value)
}).AsQueryable();
return bags;
I keep having the following error:
System.NullReferenceException: Object reference not set to an instance
of an object
On the following code line:
orderby b.Element("Updated").Value descending
I also get the same error if I add the following_
where b.Element("Name").Value == name
My XML file is as follows:
<?xml version="1.0" encoding="utf-8"?>
<Bags>
<Bag>
<Id>44334552-f7bc-4697-a5c8-e392a0ceff8b</Id>
<Content>sdsdf</Content>
<Created>13-06-2009 21:00:35</Created>
<Name>sdffsaf</Name>
<Open>True</Open>
<Updated>13-06-2009 21:00:35</Updated>
</Bag>
<Bag>
<Id>e82d6fed-0982-4260-a955-203525c4bad5</Id>
<Content>sadfdsf</Content>
<Created>13-06-2009 21:02:03</Created>
<Name>sdf</Name>
<Open>True</Open>
<Updated>13-06-2009 21:02:03</Updated>
</Bag>
</Bags>
What am I doing wrong?
Thanks,
Miguel
I have the following query:
IQueryable<Bag> bags = (from b in context.Elements("Bags")
orderby b.Element("Updated").Value
descending
select new Bag {
Id = new Guid(b.Element("Id").Value),
Content = b.Element("Content").Value,
Created = DateTime.Parse(b.Element
("Created").Value),
Name = b.Element("Name").Value,
Open = Boolean.Parse(b.Element
("Open").Value),
Updated = DateTime.Parse(b.Element
("Updated").Value)
}).AsQueryable();
return bags;
I keep having the following error:
System.NullReferenceException: Object reference not set to an instance
of an object
On the following code line:
orderby b.Element("Updated").Value descending
I also get the same error if I add the following_
where b.Element("Name").Value == name
My XML file is as follows:
<?xml version="1.0" encoding="utf-8"?>
<Bags>
<Bag>
<Id>44334552-f7bc-4697-a5c8-e392a0ceff8b</Id>
<Content>sdsdf</Content>
<Created>13-06-2009 21:00:35</Created>
<Name>sdffsaf</Name>
<Open>True</Open>
<Updated>13-06-2009 21:00:35</Updated>
</Bag>
<Bag>
<Id>e82d6fed-0982-4260-a955-203525c4bad5</Id>
<Content>sadfdsf</Content>
<Created>13-06-2009 21:02:03</Created>
<Name>sdf</Name>
<Open>True</Open>
<Updated>13-06-2009 21:02:03</Updated>
</Bag>
</Bags>
What am I doing wrong?
Thanks,
Miguel