FAQ Database Discussion Community


“Expression type 'NhDistinctExpression' is not supported by this SelectClauseVisitor.” - with Query Syntax

c#,linq-query-syntax
Given the following expression, how do I go about getting a distinct list of venues, without getting that nasty "Expression type 'NhDistinctExpression' is not supported by this SelectClauseVisitor." error? public Dictionary<int, string> GetScheduledVenuesFuture() { var venues = from v in _sp.CurrentSessionOn(DatabaseName.MyDB).Query<Venue>() join s in _sp.CurrentSessionOn(DatabaseName.MyDB).Query<ScheduledClass>() on v.VenueId equals s.Venue.VenueId where...

Linq Conditional DefaultIfEmpty query filter

c#,linq,asp.net-mvc-5,linq-query-syntax
I have a query as below: bool variable = false//or true var query = from e in _repository.GetAll<Entity>() from u in e.Users where (e.AuditQuestionGroupId != null ? e.AuditQuestionGroupId : 0) == this.LoggedInEntity.AuditQuestionGroupId from p in e.PractitionerProfiles.DefaultIfEmpty() select new { entity = e, user = u, profile = p }; This...

IQueryable Where only class name is known

c#,linq,nhibernate,linq-query-syntax
What I have: session.Query<Symptom>().First(); What I am trying to do: var className="Symptom" session.Query<className>().First() Is it possible to do this in some way? If yes where to look because I've tried with Type.GetType etc, without success. And secondary question, I have to send via web request "type" that will be in...

Want to sum fee in query month wise

c#,linq,entity-framework,linq-to-entities,linq-query-syntax
var TotalFee = (from item in _dbEntities.MonthlyFees where item.Year == DateTime.Now.Year && item.FeeStatus == true select item).GroupBy(x =>x.MonthID);//.AsEnumerable().Sum(x => int.Parse(x)); I want to sum Column "Fee" which is nvarchar type and group it by MonthID...

How to sum a single row with multiple columns in linq query

c#,linq,entity-framework,linq-to-entities,linq-query-syntax
(from item in _dbEntities.Bills where item.Year == year select item).GroupBy(x => x.MonthID).Sum(x => x.Phone); I want to sum all utility bills month wise like January there are 4 bills electricity, phone, water,gas.. these are in a single row in table how to get sum of these all and groupby...