Skip to content

Instantly share code, notes, and snippets.

@mikeedwards83
Created August 23, 2011 05:30
Show Gist options
  • Save mikeedwards83/1164417 to your computer and use it in GitHub Desktop.
Save mikeedwards83/1164417 to your computer and use it in GitHub Desktop.
Example of potential strongly typed Sitecore Query using Glass.Sitecore.Mapper
[SitecoreClass]
public class DummyClass{
[SitecoreField]
public virtual string MyField{get;set;}
[SitecoreField]
public virtual DateTime Date{get;set;}
}
string query = Query
.I("sitecore")
.I("content")
.I("*", Where<DummyClass>(x => x.MyField).Eq("someValue").Add(x => x.Date).EqLs(DateTime.Now));
Assert.AreEqual("/sitecore/content[@MyField='someValue' and @Date <= '20110822T101524']", query);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment