Potential .NET x86 JIT issue?

I can reproduce your behavior: R:\>csc /platform:x86 releasable.cs Microsoft (R) Visual C# 2010 Compiler version 4.0.30319.1 Copyright (C) Microsoft Corporation. All rights reserved. R:\>releasable Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object. at Test.Program.Main(String[] args) R:\>csc /o+ /platform:x86 releasable.cs Microsoft (R) Visual C# 2010 Compiler version 4.0.30319.1 Copyright (C) Microsoft … Read more

Dapper AddDynamicParams for IN statement with “dynamic” parameter name

I have just submitted a fix to the repository that allows any of the following to work correctly: by object (this worked previously): values.AddDynamicParams(new { ids = list }); or, by single name: values.Add(“ids”, list); or, as a dictionary: var args = new Dictionary<string, object>(); args.Add(“ids”, list); values.AddDynamicParams(args); I have not yet deployed to NuGet. … Read more

Can I join a table to a list using linq? [duplicate]

You probably found out that you can’t join an Entity Framework LINQ query with a local list of entity objects, because it can’t be translated into SQL. I would preselect the database data on the account numbers only and then join in memory. var accountNumbers = lstFarmerProfiles.Select(x => x.AccountNo).ToArray(); var duplicationChecklist = from profile in … Read more

mapping multiple tables to a single entity class in entity framework

You can use Entity Splitting to achieve this if you have the same primary key in both tables. modelBuilder.Entity<TestResult>() .Map(m => { m.Properties(t => new { t.Name, t.Text, t.Units /*other props*/ }); m.ToTable(“Result”); }) .Map(m => { m.Properties(t => new { t.Status, t.Analysis /*other props*/}); m.ToTable(“Test”); }); Here’s a useful article

How to parse my json string in C#(4.0)using Newtonsoft.Json package?

foreach (var data in dynObj.quizlist) { foreach (var data1 in data.QUIZ.QPROP) { Response.Write(“Name” + “:” + data1.name + “<br>”); Response.Write(“Intro” + “:” + data1.intro + “<br>”); Response.Write(“Timeopen” + “:” + data1.timeopen + “<br>”); Response.Write(“Timeclose” + “:” + data1.timeclose + “<br>”); Response.Write(“Timelimit” + “:” + data1.timelimit + “<br>”); Response.Write(“Noofques” + “:” + data1.noofques + “<br>”); foreach … Read more

What colon ( : ) means defining a class in c#?

In this case it means that the HomeController inherits the Controller class. You can read more details about inheritance here, but simply put – inheritance means that everything a Controller is, a HomeController is also. A HomeController is a more finely grained Controller class. It can also be used for implementation of interfaces http://msdn.microsoft.com/en-us/library/ms173156.aspx

xml error: Non white space characters cannot be added to content

It looks like you’re attempting to load an XML file into an XDocument, but to do so you need to call XDocument.Load(“C:\\temp\\contacts.xml”); – you can’t pass an XML file into the constructor. You can also load a string of XML with XDocument.Parse(stringXml);. Change your first line to: var doc = XDocument.Load(“c:\\temp\\contacts.xml”); And it will work. … Read more

how to save exception in txt file?

Since you want to save the exception to C:\Error.txt, you don’t need Directory.Exists, Directory.CreateDirectory, or Server.MapPath(“~/Error.txt”). You can simply use StreamWriter like this: string filePath = @”C:\Error.txt”; Exception ex = … using( StreamWriter writer = new StreamWriter( filePath, true ) ) { writer.WriteLine( “—————————————————————————–” ); writer.WriteLine( “Date : ” + DateTime.Now.ToString() ); writer.WriteLine(); while( ex … Read more

List thread safety

No! It is not safe at all, because processed.Add is not. You can do following: items.AsParallel().Select(item => SomeProcessingFunc(item)).ToList(); Keep in mind that Parallel.ForEach was created mostly for imperative operations for each element of sequence. What you do is map: project each value of sequence. That is what Select was created for. AsParallel scales it across … Read more

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