Solution
I needed to update Nhibernate from version 3.1.0.4000 to 3.2.0.4000. My guess is that only 3.2+ has the extra Nhqueryable LINQ support. Btw, I am using NhQueryable because it appears to bind to JqGrid much faster that a regular IQueryable: better performance for JqGrid, hurrah!
Original Issue
Not sure my terminology or understanding is up to snuff to be able to ask this clearly:
I'm using asp.net, mvc3, and nhibernate(fluent). On one project I'm maintaining, I'm able to use LINQ extension methods (such as .Where()) with NhQueryable objects. On a second project, the only NhQueryable method available is .As<>().
What configuration/library/class am I missing in the second project? Nothing stands out to me in the first project where NhQueryable can use the LINQ extension methods.
Check that both projects are referencing the same version of NHibernate, one might be using an older version which does not have linq support.
If they are both using the same version, check that the correct namespaces have been added or you won't see the extension methods in Visual Studio.
Related
I have a need to use dynamic LINQ where I can use variables in place of field names. Now I have done some googling and found that there is a sample for VS2008 where we can get this functionality.
My question is what has happened to this DLINQ ? It's been 4 years and I wonder whether it's made it into framework proper or some other new solutions have been invented to replace this? I only have my interest in DLINQ now so it is rather difficult to find further info on google, beside not knowing what exactly I am looking for other than 'better incarnation of DLINQ'. Can anyone shed some light?
This was never an "official" part of LINQ so has never been included in the framework.
The source was freely available and versions of it have appeared in CodePlex and on GitHub
The GitHub source appears to be the origin of the Nuget package
I've resurrected Dynamic LINQ, adding support for .NET 4.0/4.5, added support documentation (a work in progress), and added lots of new features.
Here is the link to the docs page, and from there, you can find the NuGet package and GitHub Project
Well I would like to know if NpgSQL supports .NET framework 4 with EntityFramework, as I tried to use it with framework 4 and Microsoft.Data.Entity.CTP (code first approach) in my MVC3 application and I found no success unfortunately.
Also if any one could lead me to any posts or links on using ADO.NET in MVC3 instead of EntiyFramework would be really helpful.
Any help would be really appreciated.
Out of box no. There is some workaround with PostgreSQL and EF, but I gave up after many attempts to force it to work. I use Telerik OpenAccess ORM. For PostgreSQL is free because database is also free. It's work with every major RDBMS. Support for Code first approach, and also database first approach (reverse enginering). In last version there is also Perfomance and tuning tool! Excellent product.
Here is link
When you asked the question I think the answer would have been no. The answer is probably irrelevant to you now but for others ...
Now I would have to say the answer is yes. I have a MVC3 (then upconverted to MVC4) project that uses code first entity framework and npgsql.
I used EF6b2 and npgsql 2.0.12.
Setting the web.config entityframework section, DbProviderFactories section and connectionstring correctly was the part the got it working. I also included the security and npgsql dlls in the project.
See
https://stackoverflow.com/a/12033304/25372
I am working with linqpad and crm 2011, cloud version, and C# snippets. Simple select queries work as advertised. Nonetheless for linqpad to be of any real use I need to get it to do updates and inserts as well and have not been able to find sample code which works or come up with any real information. Several kinds of things which show up in sample code I see around the net are missing. in particular, TestDataContext appears to be part of one or more assemblies which get loaded with linq-sql projects in Visual Studio, but is not in evidence on linqpad. SubmitChanges is not there, and it is not clear what I'd have to do to get at it or to instantiate a new DataContext object and try to use its submitchanges method.
Any usable information would be appreciated.
Well I don't know the CRM 2011 LINQ implementation. Does LINQPad have direct support for that?
Anyway, you basically can run any C# code in LINQPad. Here's a step-by-step guide how to run the needed code:
You need to add the required framework assemblies (maybe take a look at your Visual Studio project). To achieve this, go to the ‘Query’->’Advanced Query Properties’. On the dialog, click on ‘Add…’, then on ‘Browse…’. Browse to the assemblies. Add the required assemblies. Keep the ‘Advanced Query Properties’-dialog open for the next step. Optinally add your own assemblies when you use types from it.
In the ‘Advanced Query Properties’-dialog go the tab ‘Additional Namespace Imports’. Add there the namespaces you need. Expecially the LINQ-namespaces of your LINQ-provider.
Click on ‘Set as default for new queries’ so that you don’t need to repeat the three steps above next time. Then we’re done.
Now you can use the LINQ-provider in LINQ-Pad. Use the 'C#-Statements'-language. Use the .Dump-method to view query results.
Now with that steps you can use any API in LINQPad. With that you can do loops and use the regular API to update objects.
Here's what worked for me in Linqpad for CRM.
Remember that the context is implied in Linqpad.
Create your new entity and load its data, then:
AddObject(entityName);
SaveChanges();
Well I am new to this ORM stuff. We have to create a large project. I read about LINQ to SQL. will it be appropriate to use it in the project of high risk. i found no problem with it personally but the thing is that there will be no going back once started.So i need some feedback from the ORM gurus here at the MSDN. Will entity framework will be better? (I am in doubt about LINK to SQL because I have read and heard negative feedback here and there)
I will be using MVC2 as the framework. So please give the feedback about LINQ to SQL in this regard.
Q2) Also I am a fan of stored procedure as they are precomputed and fasten up the thing and I have never worked without them.I know that LINQ to SQL support stored procedures but will it be feasible to give up stored procedure seeing the beautiful data access layer generated with little effort as we are also in a need of rapid development.
Q3) If some changes to some fields required in the database in LINK to SQL how will the changes be accommodated in the data access layer.
When it comes to Linq-to-Sql vs Entity Framework, I strongly suggest to use Entity Framework. With the release of .NET 4.0 and VS2010, Microsoft added soooo much goodness in Entity Framework(EF) 4.0. Let me just mention a few points: POCO and NTier support (this means that you can have a separate library with your simple entity classes and of course EF will still be aware of them), Lazy Loading, Sql query optimizations...Also you can let EF to generate your entities (and you have the option modify the T4 generation template) or you can create them by hand if you need more control. Also, if you app will indeed be large, with EF 4, now you can separate your layers quite nicely(you can create your Mocks fo testing etc...). I'm not a web developer, so I cannot give you any hints on mvc2 on this matter.
q2-q3) - in EF you can have precompiled queries - IF you observer later on that query performance is not quite what you need. This will speed-up things quite a bit. If you plan to use EF and if you add a few changed to you database, you can easily update your model with a click.
I know I babbled too much on EF and not Linq to sql :), but hey...I believe this suits way better on your needs and you should definitely check it out for this project. Also, I don't know how much Microsoft will add features / invest in LinqToSql in the future.
Cheers,
ok precompiled queries that certainly is catching my attention.
I often get in a position when I need to know why my LINQ doesnt work as intended...
I use object collections and extensions.
I dont want spend more than couple of minutes on it. LINQ supposed to make developer's life easier not harder.
I hoped VS 2010 will have it fixed but I now use RC and it still doesnt let me type LINQ and check what is going on... Says as before "Expression cannot contain lambda expressions"...
Is there some add-on for Visual Studio so I can quickly and effectively run ad-hoc queries and find out what is going on and where I am wrong?
It's not a VS plugin, but it's free and it's awesome: LinqPad
Check it out here
You can run whatever linq or code snippet in general, just give it a look, it's an incredibly useful tool, for linq and more.
Have you tried this?
Debugging LINQ Queries
Debugging LINQ queries can be
problematic. One of the reasons is
that quite often, you write a large
query as a single expression, and you
can’t set a breakpoint mid-expression.
Writing large queries in expression
context is particularly powerful when
using functional construction to form
XML (or using the strongly typed DOM
in Open XML SDK V2). This post
presents a little trick that makes it
easier to use the debugger with LINQ
queries that are written using ‘method
syntax’.
VS 2010 isn't going to address this..
There is, in fact, such a plugin as you describe, but unfortunately it is highly expiremental. You will probably need to install VS2008 SDK and the Service Packs to get it to work - I know I did..
Here is the link:
http://extendedimmediatewin.codeplex.com/