.net-4.0

Entity framework Include command - Left or inner join?

我只是一个虾纸丫 提交于 2019-12-03 19:44:17
问题 As I was investigating the difference between Include and Join I found that : If the DB does not include a Foreign Keys -it has no navigation props so it's better to use Join If It does have a navigation props - then use Include . ( it also save a db hit.) But one answer here caught my attention: Include is implemented as a join. Depending on the nullability of the included link it is an inner or left join. Question : How does the nullity affects the left / inner join ? In Sql server I can

Typed Dataset not using TypedTableBase in .NET 4

醉酒当歌 提交于 2019-12-03 18:10:00
问题 I'm migrating our DAL class library to .NET 4 (from .NET 3.5). We're using typed datasets quite often, and we often iterate over tables: foreach(var row in ds.MyTable) var tmp = row.ID; This does not work anymore, as the designer changes the dataset's code so that tables do not derive from TypedTableBase<T> anymore, but from DataTable (and implement the non-generic IEnumerable ). That's what the diff shows. Therefore, the row is of type object at compile-time. Does anybody know if this is the

Entity framework calling a FOR XML stored procedure truncates at 2033 characters

ぐ巨炮叔叔 提交于 2019-12-03 18:03:08
问题 I have a stored procedure which uses a FOR XML statement at the end of it, and returns me some XML. I am using .NET 4 and the Entity Framework and when I do a function import of this stored procedure and try to call it through the Entity Framework it truncates the return at 2033 characters. I swapped the Entity Framework for a traditional ADO.NET approach to call the stored procedure which had the same problem - truncated at 2033 characters - which is when I came across the following MSDN

IIS 7.0 / Windows Server 2008 - DLL not found in ASP.NET application

百般思念 提交于 2019-12-03 17:37:20
I try to run an ASPX page hosted on a Windows Server 2008 x86 through IIS 7.0, with .NET 4.0. I added an application, app1 , to the Default Web Site of IIS, mapped to dir C:\toto\app1 which contains the Web.config file. The error I have is: Could not load file or assembly 'xxx.dll' or one of its dependencies , etc and xxx.dll is a .NET DLL that wraps native C++ DLLs ( they are the dependencies that fail to be loaded), all of them are located in C:\toto\app1\bin . I tried to modify the PATH env variable so that it contained the bin directory (yes, I know it's bad :-) ), but this did not work

Parallel calculation of BigInteger factorial

不羁的心 提交于 2019-12-03 17:26:21
As a part of my BigDecimal library, I need to calculate the factorial of any given non negative integer. So I'm using .Net 4.0 's System.Numerics.BigInteger to be able to store huge numbers. Here is the function I'm using: private BigInteger Factorial(BigInteger x) { BigInteger res = x; x--; while (x > 1) { res *= x; x--; } return res; } It's working but not optimized. Now I want to use parallel computing, so here is what I've tried: (I have no experience with parallel programming) public BigInteger Factorial(long x) { BigInteger res = 1; ParallelLoopResult r = Parallel.For(2L, (x + 1), i =>

BinaryFormatter can't find 'Assembly' upon deserialize in c#

狂风中的少年 提交于 2019-12-03 17:23:37
I have a program that serializes and deserializes calls, and when I try to attach my DLL to another program, it says: Unable to find assembly 'ASCOM.BHOProxy.Connector, Version=1.0.0.0, Culture=neutral, PublicKeyToken=74643865492aa2e6'. I could understand if this was a reference problem or something, but the problem is that the code that throws the exception is in ASCOM.BHOProxy.Connector . I've thought of going with some kind of third party Serializer, but I'm not quite sure what to use. The assembly is loaded by another DLL which is loaded by the application. The serialized data gets

.NET 4.0 slower than earlier versions, is that true? [duplicate]

亡梦爱人 提交于 2019-12-03 17:13:41
Possible Duplicate: Are .NET 4.0 Runtime slower than .NET 2.0 Runtime? Hello All, We are planning to move to .NET framework 4.0 sometime soon... I don't remember the refernce or link, but recently, I read about the latest framework being a little slow in performance when compared to its predecessors. Is that true? has anybody done any tests or have some valid arguments to support this? It is impossible to make a general statement about the performance of .NET 4.0 compared to earlier versions. Microsoft is constantly improving the framework, thus making performance improvements. Performance is

How to check if a user exists on LDAP

不羁的心 提交于 2019-12-03 16:46:24
I need to verify users in the company using only their username - not their password. So I need a method like this public bool UserExists(string username) { ... } I am aware of the System.DirectoryServices namespace but don't know where to start. Any ideas? There are 80,000+ records so try to bear that in mind. Thank you. Edit: I have done it - my code is: private bool UserExists(string userName, string domain) { try { DirectoryEntry.Exists("WinNT://" + domain + ".[hidden].com/" + userName); return true; } catch (COMException) { return false; } } I don't know if it is correct, but it seems to

Understanding ValidationContext in DataAnnotations

假如想象 提交于 2019-12-03 16:25:01
问题 I want to utilize Validator.TryValidateValue() but don't understand the mechanics. Say, i have the following: public class User { [Required(AllowEmptyStrings = false)] [StringLength(6)] public string Name { get; set; } } and the method: public void CreateUser(string name) {...} My validation code is: ValidationAttribute[] attrs = bit of reflection here to populate from User class var ctx = new ValidationContext(name, null, null); var errors = new List<ValidationResult>(); bool valid =

URL Encoding in c# and Asp.net web api

点点圈 提交于 2019-12-03 16:17:41
I have an ASP.NET web api that receives web requests and returns Json data. browsing to this URL: http://1.2.3.4/api1/api/values/mypartname will return the following json string: { \"PartName\": \"mypartname\", \"PartDes\": \"53.6X53.6APA/ALIM1NOTPAK\", \"PartLocation\": \"A36\" } but when sending a part name that contains spaces or quotes like this: http://1.2.3.4/api1/api/values/my part na"me i get a 404 - File or directory not found. error. I'm consuming the json with a .NET 4 Console application like so: static void Main(string[] args) { try { string partName = "TAPE 56 3M 3/4\"";