Can’t get EntityFunctions.TruncateTime() to work

I faced this problem recently when I upgraded my Web Application from Entity Framework 5 to Entity Framework 6. Then, I realized that System.Data.Entity DLL needs to be removed from the application completely in order to work with Entity Framework 6. Entity Framework 6 is not part of .NET Framework anymore and therefore it is … Read more

What is the equivalent to cron jobs in ASP.NET?

Try Quartz.NET. It’s a decent .NET scheduler which supports CRON expressions, CRON triggers and various other means and methods to schedule tasks to be performed at certain times / intervals. It even includes a basic Quartz.NET server (Windows Application) that might fit your needs. Edit: If you can’t run applications or windows services within your … Read more

What does mean “?” after variable in C#?

Well, ?. is a null-conditional operator https://msdn.microsoft.com/en-us/library/dn986595.aspx x?.y means return null if x is null and x.y otherwise ?? is a null-coalescing operator https://msdn.microsoft.com/en-us/library/ms173224.aspx x ?? y means if x == null return y, otherwise x Combining all the above helper?.Settings.HasConfig ?? false means: return false if helper == null or helper.Settings.HasConfig == null otherwise … Read more

IQueryable order by two or more properties

OrderBy(i => i.PropertyName).ThenBy(i => i.AnotherProperty) In OrderBy and ThenBy you have to provide keySelector function, which chooses key for sorting from object. So if you know property name only at runtime then you can make such function with Reflection like: var propertyInfo = i.GetType().GetProperty(“PropertyName”); var sortedList = myList.OrderBy(i => propertyInfo.GetValue(i, null)) But it will be … Read more

Best ORM to use with C# 4.0 [closed]

UPDATE 2016 Six years later things are VERY different. NHibernate is all but abandoned, other alternatives were abandoned (eg Subsonic), Entity Framework is perhaps the most common full-featured ORM, and people have been moving to micro ORMs like Dapper for years, to map from queries to objects with a minimum of overhead. The application scenarios … Read more

Dynamic parameter causes compiler to think method return is dynamic

Yes, dynamic stops the compiler from knowing the type on any parameters, properties, or method return types. Add an explicit cast like: (MethodResult)IsValid(someObject)); The reason here is that once you enter the dynamic world in C# you are going into late binding. The compiler can’t verify this code because it can no longer use any … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)