queryover

NHibernate QueryOver and MYSQL

佐手、 提交于 2019-12-11 19:19:51
问题 Hi I need help with making QueryOver in NHibernate from MYSQL. MYSQL code looks like this select lietadlo.id,lietadlo.volne,spolocnost.name,typ.name,typ.miest from lietadlo join spolocnost on spolocnost.id = lietadlo.spolocnostt_id join typ on typ.id = lietadlo.typp_id where spolocnost.pocetlietadiel > 2 And then how can i write it in Data Grid View ? Edit: So I have done so far this and try it(works good) ISessionFactory factory = new NHibernate.Cfg.Configuration().Configure()

Select items with no many-to-many relations in NHibernate?

Deadly 提交于 2019-12-11 15:09:07
问题 I have this database structure: Products ProductId Categories CategoryId ProductsInCategories ProductId CategoryId I need to find all the products that are not in a category. Right now, I use this code: var results = Session .CreateCriteria<Product>() .List<Product>() .Where(product=> !product.Categories.Any()) .ToList(); So I return all the products in my database, then filter them. This is inefficient, I need a better method. I tried this code: var res = Session.QueryOver<Product>() .Left

How to call Oracle's regexp_like function with Nhibernate QueryOver?

依然范特西╮ 提交于 2019-12-11 12:41:23
问题 I'm aware I need to use Restrictions.Eq and Projections.SqlFunction, but I've been trying for hours without any success (my test app just crashes). Does anyone have an QueryOver example that would do the following in Oracle: SELECT * FROM V_LOG_ENTRIES WHERE regexp_like(ENTRY_TEXT, '(\WPlaced\W)'); UPDATE: Okay, I think part of the problem is that Restrictions.Eq expects an equality, but there is no equality in this case, it's just a function call in the WHERE clause... 回答1: The syntax should

NHibernate comparison constraint to a coalesced date

纵然是瞬间 提交于 2019-12-11 12:15:37
问题 There is a great Q/A to prefacing this question here: NHibernate COALESCE issue I need to be able to compare a date object to a date value from within an inner join. The unfamiliar territory here has been the implementation of this COALESCE along with the date LT constraint Here is my current SQL query SELECT DISTINCT Sites.* FROM Sites INNER JOIN Sites_WF_Info ON Site_Key = SiteWFInfo_Site_Key AND SiteWFInfo_Effective_Date <= @today AND @today <= SiteWFInfo_End_Date INNER JOIN Profit_Centers

QueryOver ProjectionList with different root entity types

▼魔方 西西 提交于 2019-12-11 10:36:27
问题 I'm having issues trying to reuse ProjectionLists in NHibernate QueryOvers. I can't work out how to reuse things for different root entities. Object model is roughly represented as: Breakfast one to many Pastry many to zero-or-one Coffee The two separate queries are roughly: session.QueryOver<Breakfast>() .Where(b => b.Id == searchId) .Inner.JoinQueryOver(b => b.Pastries, () => pastry) .Left.JoinAlias(p => p.Coffee, () => coffee) .Select(projections) .TransformUsing(Transformers.AliasToBean

Nhibernate 4 API documentation

耗尽温柔 提交于 2019-12-11 10:36:18
问题 I am not able to find which namespace contains what for methods. e.g. NHibernate.IQueryOver does not contain a definition for 'Add' and no extension method 'Add' accepting a first argument of type . Visual studio is not helping to get appropriate method on using because of extension method. How can I know which methods, namespaces should be included? 回答1: In case, that we want to pass QueryOver into another method, and execute some filtering over it, we MUST know the type, which is passed.

SQLCriterion ArgumentOutOfRangeException

故事扮演 提交于 2019-12-11 10:14:51
问题 What is the correct syntax to create a SQLCriterion? I have the following code: var sqlCriterion = new SQLCriterion( new SqlString("{alias}.Id IN (SELECT Id FROM dbo.fGetSomeIds(?1, ?2))"), new object[] { "param1", "param2" }, new IType[] { NHibernateUtil.String, NHibernateUtil.String }); query.Where(sqlCriterion); where query is my QueryOver-instance (created with NHibernateSession) When I call query.List() I get the following exception: Index was out of range. Must be non-negative and less

How do I express a query containing a WHERE..IN subquery using NHibernate's QueryOver API?

北战南征 提交于 2019-12-11 09:32:35
问题 I have an object model where an Order contains many LineItems , and each LineItem has an associated Product . In the object model, these are one-way associations -- a LineItem does not know anything about its Order . I want to query for orders that contain a line item with a product name matching a string, returning one row for each order (so that paging can be performed). SELECT * FROM Orders WHERE OrderID IN ( SELECT DISTINCT OrderID FROM LineItems INNER JOIN Products on LineItems.ProductID

Find entities that match all list elements in a list

…衆ロ難τιáo~ 提交于 2019-12-11 07:45:50
问题 I have the following (simplified) many-to-many relationship: public class Tag { public string Name { get; set; } public IList<Product> Products { get; set; } } public class Product { public IList<Tag> Tags { get; set; } } The following snippet returns all products that match at least one tag: var searchTags = new[] {"tag1", "tag3"}; Tag tagAlias = null; var query = _session.QueryOver<Product>() .JoinAlias(p => p.Tags, () => tagAlias) .WhereRestrictionOn(() => tagAlias.Name).IsIn(searchTags)

Join several queries to optimise QueryOver query

冷暖自知 提交于 2019-12-11 06:58:29
问题 I am using NHibernate and while traversing my code I came upon two functions that are called in sequence. They are probably a school example of 1) extra database round trip and 2) in-memory processing at the application side. The code involved is: // 1) Getting the surveys in advance var surveys = DatabaseServices.Session.QueryOver<Survey>() .Where(x => x.AboutCompany.IsIn(companyAccounts.ToList())) // Actual query that can be optimized var unverifiedSurveys = DatabaseServices.Session