Try this..... <import class="AccountingManager.Model.AccountSummary, AccountingManager.Model" Rename="AccountSummary"/>
In my case hql worked... On Jun 16, 3:33 am, Fabio Maulo <[email protected]> wrote: > mmm..... I think you are forgetting something... no?for example... what > about the FullName of the class ? > where is the name space ? > > 2009/6/15 Chris Nicola <[email protected]> > > > > > Ok I am trying this out but with little success. I have a class defined as > > follows: > > > public class AccountSummary > > { > > public AccountSummary() > > {} > > > public AccountSummary(string accountnumber, string accountname, > > decimal creditamount, decimal debitamount, DateTime dateposted) > > { > > AccountNumber = accountnumber; > > AccountName = accountname; > > CreditAmount = creditamount; > > DebitAmount = debitamount; > > DatePosted = dateposted; > > } > > > public virtual Account Account { get; set; } > > public virtual string AccountNumber > > { get; set; } > > > public virtual string AccountName > > { > > get; set; > > } > > public virtual Decimal CreditAmount { get; set; } > > public virtual Decimal DebitAmount { get; set; } > > public virtual DateTime DatePosted { get; set; } > > } > > > Then I have an import map for it: > > > <import class="AccountSummary, AccountingManager.Model"/> > > > Finally I have an HQL query like this: > > > var query = "select new AccountSummary(a.Number, a.Name , sum(e.Amount * (1 > > - e.IsDebit)), sum(e.Amount * e.IsDebit) , e.DatePosted) " + > > "from Entry as e " + > > "join e.Account as a " + > > Where + > > "group by a.Number, a.Name, e.IsDebit, > > e.DatePosted"; > > var hql = session.CreateQuery(query); > > return hql.Future<AccountSummary>(); > > > Just to explain what I am doing (which could be my problem) I am > > multiplying Amount by IsDebit which is a boolean to get two sums one for > > debits and one for credits. > > > I get this error: > > > System.TypeLoadException: Could not load type 'AccountSummary' from > > assembly 'AccountingManager.Model, Version=1.0.0.0, Culture=neutral, > > PublicKeyToken=null'. > > at System.Reflection.Assembly._GetType(String name, Boolean throwOnError, > > Boolean ignoreCase) > > at System.Reflection.Assembly.GetType(String name, Boolean throwOnError) > > at NHibernate.Util.ReflectHelper.TypeFromAssembly( > > AssemblyQualifiedTypeName name, Boolean throwOnError) > > at NHibernate.Util.ReflectHelper.ClassForName(String name) > > at NHibernate.Hql.Ast.ANTLR.Tree.ConstructorNode.ResolveConstructor(String > > path) > > > I understand this type of error can occur when the constructor types don't > > match the query output. Do I need to cast the query output somehow or did I > > do something completely wrong? > > > Thanks for your help, > > Chris > > > On Tue, Jun 9, 2009 at 11:12 AM, Fabio Maulo <[email protected]> wrote: > > >> probably is not support by actual implementation of Linq2NH.btw using > >> <import> you can "map" you DTO (AccountTake). > > >> 2009/6/9 Chris Nicola <[email protected]> > > >> I am trying this as a Linq query: > > >>> var query = from entry in entryquery > >>> group entry by entry.Account into list > >>> select new AccountTake > >>> { > >>> Account = list.Key, > >>> CreditAmount = list.Sum(p => p.Amount), > >>> DebitAmount = list.Sum(p => p.Amount) > >>> }; > > >>> And this is the resulting SQL > > >>> SELECT sum(this_.Amount) as y0_, > >>> sum(this_.Amount) as y1_ > >>> FROM Entries this_ > > >>> Seems to be ignoring group by. Obviously this returns an exception as it > >>> can't map that to AccountTake. > > >>> Chris > > >>> On Wed, Jun 3, 2009 at 3:53 PM, Fabio Maulo <[email protected]>wrote: > > >>>> Not with anonymous type but with a real Type or a IList<object[]> > > >>>> 1)select e.Key, sum(e.Amount) from Entry e group by e.Key > >>>> 2)select new YourStatisticEntry(e.Key, sum(e.Amount)) from Entry e group > >>>> by e.Key > >>>> 3) using 1 with a results trasformer to transform each result or the > >>>> entirely IList. > > >>>> 2009/5/28 Chris Nicola <[email protected]> > > >>>> I was wondering if it is possible to do simple sums and groupings with > >>>>> Linq2Nhibernate without returning the entire result set first using > >>>>> .ToList(); > > >>>>> My scenario: > > >>>>> I have a table of accounts, and for each and every account I would like > >>>>> to get a sum of transactions from three different tables. In SQL I > >>>>> would do > >>>>> something like > > >>>>> SELECT SUM(Amount), Account.id > >>>>> FROM Entries > >>>>> Group By Account.id > > >>>>> In a Linq query I might try to return something like: > > >>>>> from entry in session.Linq<Entry>() > >>>>> group entry by entry.Account into list > >>>>> select new > >>>>> { > >>>>> Account = list.Key, > >>>>> Total = list.Sum(e => e.Amount) > >>>>> }; > > >>>>> However that returns an error because nHibernate is expecting to return > >>>>> entities of type <Entry> and not the anonymous type I just defined. > > >>>>> Is there any way to get results like this? > > >>>>> Thanks, > >>>>> Chris > > >>>> -- > >>>> Fabio Maulo > > >> -- > >> Fabio Maulo > > -- > Fabio Maulo --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
