Je vais avoir des problèmes avec la déclaration suivante, qui retourne l'erreur "séquence ne contient aucun élément":Aide avec SQL/LINQ Debugging
var vUser = (from u in this.dcLAUNCHOnline.aspnet_Users
where u.UserName.Equals(this.wCreateUser.UserName)
select u).Single();
Le SQL généré:
SELECT [t0].[ApplicationId],
[t0].[UserId],
[t0].[UserName],
[t0].[LoweredUserName],
[t0].[MobileAlias],
[t0].[IsAnonymous],
[t0].[LastActivityDate],
[t0].[FirstName],
[t0].[LastName],
[t0].[Address_Street],
[t0].[Address_City],
[t0].[Address_Province],
[t0].[Address_Country],
[t0].[Address_PostalCode],
[t0].[Telephone_Main_AreaCode],
[t0].[Telephone_Main_Prefix],
[t0].[Telephone_Main_LineNumber],
[t0].[Telephone_Main_Extension],
[t0].[Telephone_Mobile_AreaCode],
[t0].[Telephone_Mobile_Prefix],
[t0].[Telephone_Mobile_LineNumber],
[t0].[Telephone_Mobile_Extension],
[t0].[Telephone_Other_AreaCode],
[t0].[Telephone_Other_Prefix],
[t0].[Telephone_Other_LineNumber],
[t0].[Telephone_Other_Extension],
[t0].[Gender],
[t0].[BirthDate]
FROM [dbo].[aspnet_Users] AS [t0]
WHERE [t0].[UserName] = @p0
-- @p0: Input NVarChar (Size = 20; Prec = 0; Scale = 0) [[email protected]]
-- Context: SqlProvider(Sql2008) Model: AttributedMetaModel Build: 3.5.30729.4918
Lorsqu'il est exécuté dans SQL Server Management Studio, le script renvoie la ligne attendue (qui est dans la table)
J'ai défini p0 avec cette ligne:
DECLARE @p0 NVarChar(20) = '[email protected]'
Des idées pour lesquelles cela échoue? Merci!
Vous avez probablement raison, j'ai négligé cet aspect. –
La chaîne de connexion était-elle :) – stringo0
@Johannes: Oui, j'ai dû relire la question pour comprendre :) – CMS