Страница 3 из 3
Страница 3 из 3


I tried to do a filter api service with this query
create proc usp_filter
@name VARCHAR(50),
@lastname VARCHAR(50),
@pass VARCHAR(50)
as
begin
SELECT * FROM tb_users
WHERE
(name = @name OR @name is null) AND
(lastname = @lastname OR @lastname is null) AND
(pass = @pass OR @pass is null)
end
gowhich filters data from a table but it can ignore some or all parameters if it is required.
so when i send the parameters in c#, it only returns the list if all parameters are entered, in case i want to send a null parameter this error is generated in the controller
Additional information: The value cannot be null.
i tried to handle this error with DbNull but i get the same error
this is my method
public List<User> Filter(string name, string lastname, string pass) { List<User> users = null; cnx.Open(); string sqlStatement = "usp_filter"; SqlCommand cmd = new SqlCommand(sqlStatement, cnx); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@name", name ?? Convert.DBNull); cmd.Parameters.AddWithValue("@lastname", lastname ?? Convert.DBNull); cmd.Parameters.AddWithValue("@pass", pass ?? Convert.DBNull); SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { users = new List<User>(); while (reader.Read()) { User user = new User(); user.id = int.Parse(reader["id"].ToString()); user.name= reader["name"].ToString(); user.lastName= reader["lastname"].ToString(); user.address= reader["address"].ToString(); user.email = reader["email"].ToString(); user.pass= reader["pass"].ToString(); users.Add(user); } } cnx.Close(); return users; }and this is how i handled it in my controller.
[HttpGet] public User Filter(string name,string lastname,string pass) { var list = business.Filter(name,lastname,pass); User user = list.Where(x => x.name == name && x.lastname == lastname && x.pass == pass).SingleOrDefault(); return user; }Edit of the exception https://i.stack.imgur.com/HKBrU.png
I am relatively new to C# and i have come across this error while working on a project to spin a VM (and support resources in MS Azure).
The code I am using is the one below:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Azure.Management.Compute.Fluent;
using Microsoft.Azure.Management.Compute.Fluent.Models;
using Microsoft.Azure.Management.Fluent;
using Microsoft.Azure.Management.ResourceManager.Fluent;
using Microsoft.Azure.Management.ResourceManager.Fluent.Core;
namespace ConsoleApp1
{ class Program { private static void Main(string[] args) { var credentials = SdkContext.AzureCredentialsFactory.FromFile(Environment.GetEnvironmentVariable("AZURE_AUTH_LOCATION")); var azure = Azure .Configure() .WithLogLevel(HttpLoggingDelegatingHandler.Level.Basic) .Authenticate(credentials) .WithDefaultSubscription();Also I have an «azureauth.properties.txt» file i used to set a new Environmental path referenced in the code above as "AZURE_AUTH_LOCATION".
To set the path i used the simple PS command:
[Environment]::SetEnvironmentVariable("AZURE_AUTH_LOCATION", "C:\MY-PATH\azureauth.properties", "User")The azureauth.properties file contains simple Tenant/application/key IDs in the format
subscription=<subscription-id>
client=<application-id>
key=<authentication-key>
tenant=<tenant-id>
managementURI=https://management.core.windows.net/
baseURL=https://management.azure.com/
authURL=https://login.windows.net/
graphURL=https://graph.windows.net/Whenever I am trying to run the project i get an error saying:
System.ArgumentNullException: ‘Value cannot be null.’
specifically for the line:
var credentials = SdkContext.AzureCredentialsFactory.FromFile(Environment.GetEnvironmentVariable("AZURE_AUTH_LOCATION"));Any idea why?
10745: [Unity] DisplayProgressbar: Compiling shader variants
10746: [Unity] DisplayProgressbar: Building Player
10747: [Unity] DisplayProgressbar: Fetching assembly references
10748: [Unity] DisplayProgressbar: Building Player
10749: [Unity] UserBlackList: /BUILD_PATH/mycompany.new-unity-project.default-ios/Assets/link.xml
10750: [Unity] UserBlackList: /BUILD_PATH/mycompany.new-unity-project.default-ios/Assets/FacebookSDK/link.xml
10751: [Unity] UserBlackList: /BUILD_PATH/mycompany.new-unity-project.default-ios/Assets/Firebase/Plugins/Crashlytics/link.xml
10752: [Unity] UserBlackList: /BUILD_PATH/mycompany.new-unity-project.default-ios/Assets/JsonDotNet/link.xml
10753: [Unity] UserBlackList: /BUILD_PATH/mycompany.new-unity-project.default-ios/Assets/Standard Assets/VoxelBusters/NativePlugins/link.xml
10754: [Unity] /UNITY_PATH/Unity/macos/published/Unity-2018_4_17f1/Unity.app/Contents/il2cpp/build/UnityLinker.exe exited after 12550 ms.
10755: [Unity] /UNITY_PATH/Unity/macos/published/Unity-2018_4_17f1/Unity.app/Contents/Tools/InternalCallRegistrationWriter/InternalCallRegistrationWriter.exe exited after 611 ms.
10756: [Unity] DisplayProgressbar: Fetching assembly references
10757: [Unity] DisplayProgressbar: Building Player
10758: [Unity] Invoking il2cpp with arguments: --convert-to-cpp --emit-null-checks --enable-array-bounds-check --dotnetprofile="unityaot" --map-file-parser="/UNITY_PATH/Unity/macos/published/Unity-2018_4_17f1/Unity.app/Contents/Tools/MapFileParser/MapFileParser" --directory="/BUILD_PATH/mycompany.new-unity-project.default-ios/Temp/StagingArea/Data/Managed" --generatedcppdir="/BUILD_PATH/mycompany.new-unity-project.default-ios/Temp/il2cppOutput/il2cppOutput"
10759: [Unity] /UNITY_PATH/Unity/macos/published/Unity-2018_4_17f1/Unity.app/Contents/il2cpp/build/il2cppcore/il2cppcore.dll exited after 197737 ms.
10760: [Unity] Unknown file extension: .so
10761: [Unity] UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
10762: [Unity] UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
10763: [Unity] UnityEngine.Logger:Log(LogType, Object)
10764: [Unity] UnityEngine.Debug:LogWarning(Object)
10765: [Unity] UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck(String[], String, String, BuildTargetGroup, BuildTarget, BuildOptions, Boolean)
10766: [Unity] UnityEditor.CloudBuild.Builder:Build()
10767: [Unity] Unknown file extension: .xml
10768: [Unity] UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
10769: [Unity] UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
10770: [Unity] UnityEngine.Logger:Log(LogType, Object)
10771: [Unity] UnityEngine.Debug:LogWarning(Object)
10772: [Unity] UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck(String[], String, String, BuildTargetGroup, BuildTarget, BuildOptions, Boolean)
10773: [Unity] UnityEditor.CloudBuild.Builder:Build()
10774: [Unity] Unknown file extension: .meta
10775: [Unity] UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
10776: [Unity] UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
10777: [Unity] UnityEngine.Logger:Log(LogType, Object)
10778: [Unity] UnityEngine.Debug:LogWarning(Object)
10779: [Unity] UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck(String[], String, String, BuildTargetGroup, BuildTarget, BuildOptions, Boolean)
10780: [Unity] UnityEditor.CloudBuild.Builder:Build()
10781: [Unity] Unknown file extension: .properties
10782: [Unity] UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
10783: [Unity] UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
10784: [Unity] UnityEngine.Logger:Log(LogType, Object)
10785: [Unity] UnityEngine.Debug:LogWarning(Object)
10786: [Unity] UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck(String[], String, String, BuildTargetGroup, BuildTarget, BuildOptions, Boolean)
10787: [Unity] UnityEditor.CloudBuild.Builder:Build()
10788: [Unity] Unknown file extension: .meta
10789: [Unity] UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
10790: [Unity] UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
10791: [Unity] UnityEngine.Logger:Log(LogType, Object)
10792: [Unity] UnityEngine.Debug:LogWarning(Object)
10793: [Unity] UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck(String[], String, String, BuildTargetGroup, BuildTarget, BuildOptions, Boolean)
10794: [Unity] UnityEditor.CloudBuild.Builder:Build()
10795: [Unity] Splash screen images not provided: Mobile Splash Screen*, iPhone 3.5''/Retina, iPhone 4''/Retina, iPhone 4.7''/Retina, iPhone 5.5''/Retina, iPhone X /Retina, iPad Portrait, iPad Portrait/Retina
10796: [Unity] UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
10797: [Unity] UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
10798: [Unity] UnityEngine.Logger:Log(LogType, Object)
10799: [Unity] UnityEngine.Debug:LogWarning(Object)
10800: [Unity] UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck(String[], String, String, BuildTargetGroup, BuildTarget, BuildOptions, Boolean)
10801: [Unity] UnityEditor.CloudBuild.Builder:Build()
10802: [Unity] [PostProcessBuild] : ModifyInfoPlist : /BUILD_PATH/mycompany.new-unity-project.default-ios/temp20200304-3773-1s9il9c
10803: [Unity] UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
10804: [Unity] UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
10805: [Unity] UnityEngine.Logger:Log(LogType, Object)
10806: [Unity] UnityEngine.Debug:Log(Object)
10807: [Unity] VoxelBusters.NativePlugins.PostProcessBuild:UpdateInfoPlist(String) (at Assets/Standard Assets/VoxelBusters/NativePlugins/Editor/PostProcessBuild.cs:277)
10808: [Unity] VoxelBusters.NativePlugins.PostProcessBuild:ExecutePostProcessAction(String) (at Assets/Standard Assets/VoxelBusters/NativePlugins/Editor/PostProcessBuild.cs:110)
10809: [Unity] VoxelBusters.NativePlugins.PostProcessBuild:OnPostProcessBuildActionStart(BuildTarget, String) (at Assets/Standard Assets/VoxelBusters/NativePlugins/Editor/PostProcessBuild.cs:75)
10810: [Unity] System.Reflection.MonoMethod:InternalInvoke(Object, Object[], Exception&)
10811: [Unity] System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)
10812: [Unity] System.Reflection.MethodBase:Invoke(Object, Object[])
10813: [Unity] UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck(String[], String, String, BuildTargetGroup, BuildTarget, BuildOptions, Boolean)
10814: [Unity] UnityEditor.CloudBuild.Builder:Build()
10815: [Unity] (Filename: Assets/Standard Assets/VoxelBusters/NativePlugins/Editor/PostProcessBuild.cs Line: 277)
10816: [Unity] [XcodeProjectModifier] Loading Xcode project '/BUILD_PATH/mycompany.new-unity-project.default-ios/temp20200304-3773-1s9il9c'.
10817: [Unity] UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
10818: [Unity] UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
10819: [Unity] UnityEngine.Logger:Log(LogType, Object)
10820: [Unity] UnityEngine.Debug:Log(Object)
10821: [Unity] Google.Logger:Log(String, LogLevel) (at /Users/smiles/dev/src/unity-jar-resolver/source/VersionHandlerImpl/src/Logger.cs:115)
10822: [Unity] Firebase.Editor.CategoryLogger:LogDebug(String, Object[]) (at Z:\tmp\tmp.saWQ0wIga5\firebase\app\client\unity\editor\src\CategoryLogger.cs:35)
10823: [Unity] Firebase.Editor.XcodeProjectModifier:.ctor(String) (at Z:\tmp\tmp.saWQ0wIga5\firebase\app\client\unity\editor\src\XcodeProjectModifier.cs:82)
10824: [Unity] Firebase.Editor.XcodeProjectModifier:PostProcessBuild(BuildTarget, String) (at Z:\tmp\tmp.saWQ0wIga5\firebase\app\client\unity\editor\src\XcodeProjectModifier.cs:159)
10825: [Unity] System.Reflection.MonoMethod:InternalInvoke(Object, Object[], Exception&)
10826: [Unity] System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)
10827: [Unity] System.Reflection.MethodBase:Invoke(Object, Object[])
10828: [Unity] UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck(String[], String, String, BuildTargetGroup, BuildTarget, BuildOptions, Boolean)
10829: [Unity] UnityEditor.CloudBuild.Builder:Build()
10830: [Unity] (Filename: /Users/smiles/dev/src/unity-jar-resolver/source/VersionHandlerImpl/src/Logger.cs Line: 115)
10831: [Unity] Uploading Crash Report
10832: [Unity] EXCEPTION: ArgumentNullException: Value cannot be null.
10833: [Unity] Parameter name: path1
10834: [Unity] UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
10835: [Unity] UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
10836: [Unity] UnityEngine.Logger:Log(LogType, Object)
10837: [Unity] UnityEngine.Debug:Log(Object)
10838: [Unity] UnityEditor.CloudBuild.BuildLogger:Log(String)
10839: [Unity] UnityEditor.CloudBuild.BuildLogger:HighlightUnityErrors(String, String, LogType)
10840: [Unity] UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
10841: [Unity] UnityEngine.DebugLogHandler:LogException(Exception, Object)
10842: [Unity] UnityEngine.Logger:LogException(Exception, Object)
10843: [Unity] UnityEngine.Debug:LogException(Exception)
10844: [Unity] UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck(String[], String, String, BuildTargetGroup, BuildTarget, BuildOptions, Boolean)
10845: [Unity] UnityEditor.CloudBuild.Builder:Build()
10846: [Unity] ArgumentNullException: Value cannot be null.
10847: [Unity] Parameter name: path1
10848: [Unity] at System.IO.Path.Combine (System.String path1, System.String path2) [0x00003] in <e1319b7195c343e79b385cd3aa43f5dc>:0
10849: [Unity] at Firebase.Editor.XcodeProjectModifier.ReadPList (System.String relFilePath) [0x00000] in Z:\tmp\tmp.saWQ0wIga5\firebase\app\client\unity\editor\src\XcodeProjectModifier.cs:179
10850: [Unity] at Firebase.Editor.XcodeProjectModifier..ctor (System.String xcodeProjDir) [0x00052] in Z:\tmp\tmp.saWQ0wIga5\firebase\app\client\unity\editor\src\XcodeProjectModifier.cs:92
10851: [Unity] at Firebase.Editor.XcodeProjectModifier.PostProcessBuild (UnityEditor.BuildTarget buildTarget, System.String pathToBuiltProject) [0x0007c] in Z:\tmp\tmp.saWQ0wIga5\firebase\app\client\unity\editor\src\XcodeProjectModifier.cs:159
10852: [Unity] at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
10853: [Unity] at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <e1319b7195c343e79b385cd3aa43f5dc>:0 





