I want to convert a NHibernate CreateCriteria over to a NHLambdaExtensions criteria, but I'm getting errors that I don't know how to fix.
The NHibernate criteria looks like this:
var departments = DepartmentService
.CreateCriteria()
.CreateAlias( "Goals", "goal" )
.Add( Expression.Eq( "goal.Company.Id", companyId ) )
.A...
The map.
public SocialCodeMap()
{
Id(x => x.SocialCodeId);
Map(x => x.Name);
Map(x => x.Code);
Map(x => x.DisplayOrder);
}
And the Class.
public class SocialCode
{
public virtual Guid SocialCodeId { get; set; }
public virtual string Name { get; set; }
public virtual char Code { ...
I have a entity 'Person' a person has a collection of Friends (also Person entities)
I want to get the first 10 Friends of a particular person, ordered by LatestLogin.
My best effort is:
public static IList<Person> GetFriends(Person person, int count)
{
Person personAlias = null;
Person friendAlias = null;
...
I've got a Criteria Query for a social networking site. A Person object has a collection of Friends (also person objects). The query grabs the first N friends, but I also want to eager load an associated object MainProfileImage and then a subsequent associated object MediumThumbnail.
I can do this in HQL easily:
select friends from P...
My application creates a dynamically generated query at runtime based on user input by creating Criterion objects e.g:
ICriterion criterion = Restrictions.Eq("Name", "John");
......
detachedCriteriaSomewhereElse.Add(criterion);
How do I do this in NHLambdaExtensions?
what I really need to do is
ICriterion criterion = Restrictions.Eq...
This is probably something simple but I seem to be lacking some knowledge of how nhibernate works. This is my code:
ICriteria query = Session.CreateCriteria();
query = query.CreateCriteria(x => x.TblProjects)
.Add<TblProject>(x => x.FldCurrentFunding != 0m)
.Add<TblProject>(x => x.FldCurrentFunding...
I'm trying to write a simple query that requires an alias as it's a Many-To-Many assocation however I can't get it to work with NH Lambda Extensions. It always gives me a compile error even though as far as I can tell it's exactly the same as the documentation and all the examples I've seen online.
Works
var query = DetachedCriteria.Fo...
I normally query interfaces using DetachedCriteria in NHibernate:
DetachedCriteria crit = DetachedCriteria.For<IParent>();
And this works fine.
I now want to create a subquery for a child object thus:
DetachedCriteria subcrit = DetachedCriteria.For<IChild>();
and add it to the criteria like this (kind of, p.Child is actually an al...
Hi ;)
I've recently implemented an IronRuby web service application for a client, to replace an existing C# .NET DLL. What the client forgot to mention was that in the mean time they implemented a new version of the DLL, with a new API based on lambda expressions. And made sure all calls (thousands :( ) use the new syntax. So now I need...
Hi everybody. I'm using NHibernate with Lambda Extensions. I'd like to know how to nest a Max function with a Substring.
The following statement retrieves Max("invoice_id")
var ret = session
.CreateCriteria<Invoice>()
.SetProjection(Projections.Max("invoice_id"))
.UniqueResult();
but in my case the field...
I'm trying to create a not in clause with the NHibernate Criteria API using NHLambdaExtensions. Reading the documentation I was able to implement the in clause by doing
.Add(SqlExpression.In<Zone>(z => zoneAlias.ZoneId, new int[] { 1008, 1010 }))
However, when I wrap it around SqlExpression.Not I get the error
Error 5 The best ov...