Posts Tagged ‘DotNet’

NHibernate Vs Entity Framework 6.0 – A Comparison

December 3, 2013

Here is a nice comparison table for NHibernate and Entity framework 6.0. This is the result of my searching and reading, to get to know over the evolution of Entity Framework (the latest is V6.0). Enjoy reading!

Feature

NHibernate

EF 1.0 to EF 6.0

Current version

V3.3.3

V 6.0

Year released

 Hibernate (JAVA) 2001/ NHibernate (.NET) 2005

2008

Introduced

.NET 1.1 and above/Mono

.NET Framework 3.5 SP1 and above

Open source

Yes

Yes from 6.0

Associations

Both supports 1 to 1, 1 to many, and many to many

Both supports  1 to 1, 1 to many, and many to many

Rich domain models

Yes

No

Ordered and unordered sets collection. Indexed options. It even has an immutable, indexed list

Yes

No

Mapping private fields (yet) or can you directly use a dictionary class

Yes

No

Collection supports

IDictionary<T,T>  IEnumerable<T>

ICollections

Supporting ENUM

Yes

Yes from 6.0

Vendor support /Providers:

SQL Server/Azure, SQLite, PostgreSQL, Oracle, Sybase, Firebird and DB2

All the DB providers are built-in

SQL Server or SQL Azure,

Code first

Yes

From EF 5.0

Code-based mapping

NHinernate 3.2 with Fluent-NHibernate

From EF 6.0

Supporting custom types and collections

Yes

No

Query flexibility

HQL/QueryOver/Criteria API/Native Vendor specific SQL (3.2 with the above & lot more)

LINQ/Entity SQL/Native SQL/Commercial  provider for ORACLE

Extensibility

Uses Listeners/Configuration properties

ServiceLocator pattern

Async/await support

No

EF 6

Built-in support for automatically reconnecting to the database

No

Yes

.NET 4.5 support

Yes

Yes (with improved performance)

Batch processing

With “Future”

No

Creating a DBContext with an existing open connection

No

Yes

Spatial support

Need 3rd party

In-built

Documentation

Poor, but can get lot of support over forum

Good

Caching

Support second-level caching

Yes from EF6

Events

“NHibernate has a very rich event model, that exposes more than 20 events, either for synchronous pre-execution or asynchronous post-execution”.

Entity Framework only has two event-based extension points: ObjectMaterialized and SavingChanges

Tracking Changes

No

While both default to change tracking at the unit of work level, Entity Framework also offers self-tracking entities.

Able to map SQL views

Yes

No

Querying SSAS OLAP cubes

No

Yes

Interception of queries/object creation

Yes

No

API Methods

Save, Update, SaveOrUpdate, SaveOrUpdateCopy, Replicate and Merge,

 

Lazy loading behavior

One an relationship by relationship basis

For the entire context

Courtesy:

http://dotnet.dzone.com/articles/entity-framework-56-vs

http://weblogs.asp.net/ricardoperes/archive/2012/06/07/differences-between-nhibernate-and-entity-framework.aspx

Misleading exception with .NET DataContractJsonSerializer() – A bug reported to http://connect.microsoft.com/

December 3, 2013
Please find below the complete text from connect.microsoft:
Note: Just copy pasted  as is, so that you may not be finding formatted nicely. 🙂
Description
I was working for serializing C# object into JSON using DataContractJsonSerializer(). Whenever the KnownType in not specified in the base class or passed into the constructor of DataContractJsonSerializer(), I have got the following exception.[Exception]
An unhandled exception of type ‘System.Runtime.Serialization.SerializationException’ occurred in System.Runtime.Serialization.dllAdditional information: Type ‘DerivedClasses.CustomerResponse’ with data contract name ‘CustomerResponse:http://schemas.datacontract.org/2004/07/DerivedClasses&#8217; is not expected. Consider using a DataContractResolver or add any types not known statically to the list of known types – for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.
[/Exception]

Details

Visual Studio/Visual Studio Online/Team Foundation Server/.NET Framework Tooling Version

.NET Framework 4.5.1

What category (if any) best represents this feedback?

Compatibility

Steps to reproduce

1). Have a base class and derived class
2). Don’t mark the base class with [KnownType] attribute
3). Populate derived object with required data
4). Try serializing derived object to JSON using DataContractJsonSerializer(), by passing the typeof(base class)

Product Language

English

Operating System

Windows 7

Operating System Language

English

Actual results

Issues with the exception:The exception what we are getting is as same as for “DataContractSerializer”.

So, this exception message is misleading by saying
1). “Consider using a DataContractResolver”, though DataContractJsonSerializer() is not supporting DataContractResolver.
2). or by adding them to the list of known types passed to “DataContractSerializer”

Expected results

The above two points in “Actual results” section needs to be removed from the exception and to be corrected with specific to “DataContractJsonSerializer”.

Locale

English Connect
Posted by laks_win on 12/2/2013 at 10:49 AM

Hi Team,I have got one more issue on the same Misleading exception with DataContractJsonSerializer() for passing the object which has “Cyclic References”. Actually DataContractJsonSerializer() doesn’t support it, but shows the exception that is specific to DataContractSerializer(). So, please have a check for this issue too.

Thanks and regards
Lakshminarayanan.R

Posted by Microsoft on 11/8/2013 at 2:39 PM

Hi Laks_win.Thank you for the feedback on WCF. This is a good suggestion and we will consider this for a future release.

Thanks,
Erica Mohler
Microsoft Program Manager

Posted by Microsoft on 10/29/2013 at 4:04 AM
Thank you for submitting feedback on Visual Studio and .NET Framework. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by laks_win on 10/24/2013 at 9:54 PM
Thanks for the follow up. Just uploaded a newly created sample zip, its for your kind perusal.
Posted by Microsoft on 10/24/2013 at 6:22 AM

Thank you for submitting feedback on Visual Studio and .NET Framework. In order to efficiently investigate and reproduce this issue, we are requesting additional information outlined below.Could you please give us a demo project to demonstrate this issue so that we can conduct further research?

We look forward to hearing from you with this information.

Posted by Microsoft on 10/23/2013 at 10:50 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)

Features in Visual Studio 2012 and ASPNET 4.5” Free E-book

August 4, 2012

There is an E-Book available for download in Telerik’s website. This e-book contains an overview of the features that would help great you as a developer :).

So, what is in this e-book you ask? Well…..

  • JavaScript Intellisense
  • CSS Intellisense
  • ASP.NET and Web API (overview and CRUD operations)
  • Strongly Typed Data Binding
  • Page Inspector (new debugging tool)
  • Etc

Here you go…

Free E-book: Time-Saving VS11 and ASP.NET 4.5 Features You Shouldn’t Miss