当我在我的c#代码中将可空的guid参数传递给存储过程时.我得到例外:
System.Data.SqlClient.SqlException(0x80131904):'@customerGuid'附近的语法不正确.
var userNameSqlParam = new SqlParameter
{
ParameterName = "userName",
Value = userName,
DbType = DbType.String
};
var customerGuidSqlParam = new SqlParameter
{
ParameterName = "customerGuid",
Value = customerGuid,
DbType = DbType.Guid
};
var rows = _dbContext.Database
.SqlQuery<CurrentUserContextWithoutCustomer>
("EXEC [dbo].[GetCurrentUserContext] @userName @customerGuid",
userNameSqlParam, customerGuidSqlParam)
.ToList();
Run Code Online (Sandbox Code Playgroud)
因此,当我通过SQL事件探查器查看我得到的内容时
exec sp_executesql
N'EXEC [dbo].[GetCurrentUserContext] @userName @customerGuid',
N'@userName nvarchar(4),@customerGuid uniqueidentifier',
@userName=N'gir1',@customerGuid=default
Run Code Online (Sandbox Code Playgroud)
我在查询结束时看到默认值.它会产生问题.有存储过程的标题
ALTER PROCEDURE [dbo].[GetCurrentUserContext]
@userName nvarchar(100),
@customerGuid uniqueidentifier
AS
Run Code Online (Sandbox Code Playgroud)
如何将可空的guid作为存储过程参数传递给sql.
我看到一些包含ThenInclude的 LINQ代码示例.我在哪里可以找到这样的方法?在外部库或其他命名空间中.
我想用这样的方法来获取派生数据,但我找不到这样的方法或者你知道其他解决方案
return _dbContext.Goals
.Where(p => p.Owner.Id == userId)
.Include(p => p.GoalExpectation)
.ThenInclude<RangeGoalExpectation>(p => p.MinValue)
.ThenInclude<RangeGoalExpectation>(p => p.MaxValue)
.ThenInclude<SpecifiedGoalExpectation>(p => p.Value)
Run Code Online (Sandbox Code Playgroud) 在dotNET中我们可以编写非托管代码,在哪里可以动态分配内存(通过关键字:stackalloc,new),使用指针等.
可以释放内存(例如通过像C++中的delete这样的东西)?
我使用Visual Studio 2012,我在那里编写简单的控制台应用程序.有谁知道如何从我的C#代码中获取MSIL代码?
我希望在没有ILDASM的编译之后看到它,可以自动执行此过程
我有字节值的枚举:
enum MarketingEventType : byte {MARKETING_CAMPAIGN, TELESALES, MARKETING_ACTIONS};
Run Code Online (Sandbox Code Playgroud)
我想给出所有元素名称,我将通过ToSting()方法获得.例如:
MarketingEventType.TELESALES.ToString(); // I get "bla bla bla"
MarketingEventType.MARKETING_ACTIONS.ToString(); // I get "la la la"
Run Code Online (Sandbox Code Playgroud)
从BYTE到STRING没有改变类型的enum是可能的吗?
为什么我不能将对象转换为十进制(代码低于,record["Cost"]等于1 (int))?
我得到以下错误
'无法取消装箱记录["费用"]'
我将使用TryParse方法,但我不明白这个错误的来源是什么.
cost = (decimal?) record["Cost"];
Run Code Online (Sandbox Code Playgroud) 我想在推送通知中向Apple手机发送自定义JSON,而无需任何其他信息.
我会发送类似的东西:
{
message: "Message bla bla"
, type: 1
, data: "Tekst"
}
Run Code Online (Sandbox Code Playgroud)
我该怎么做?
我在 SQL Server 2012 Express 中编写了这个存储过程。
ALTER PROCEDURE [Dictionaries].[InsertCountry]
(@p_countryName nvarchar(128)
, @ret_countryId int OUTPUT)
AS
BEGIN
DECLARE @TransactionName VARCHAR(20) = 'INST_COUNTRY';
BEGIN TRANSACTION @TransactionName;
IF len(@p_countryName) <= 3
BEGIN
SET @ret_countryId = null
ROLLBACK TRANSACTION @TransactionName;
END
INSERT INTO [Dictionaries].[CountryDetails] (name)
VALUES (@p_countryName);
SET @ret_countryId = @@IDENTITY
INSERT INTO [Dictionaries].[Places] (name, Discriminator , CountryDetails_Id, RegionDetails_Id, CityDetails_Id)
VALUES (@p_countryName, 'Country' , @ret_countryId, null, null);
COMMIT TRANSACTION @TransactionName;
END
Run Code Online (Sandbox Code Playgroud)
我以这种方式使用这个方法,但我收到消息
COMMIT TRANSACTION 请求没有对应的 BEGIN TRANSACTION。
代码:
declare @ret int = null …Run Code Online (Sandbox Code Playgroud) 我有 WPF 中的用户控制代码(如下)。我使用 nInject 作为 IocContainer。我在 App 类的 OnStartup 事件中初始化 ioc。
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
var iocContainer = IocContainer.Get();
iocContainer.Bind<CreateRemindPopup>().To<CreateRemindPopup>();
iocContainer.Bind<MainWindow>().To<MainWindow>();
Current.MainWindow = iocContainer.Get<MainWindow>();
Current.MainWindow.Show();
}
Run Code Online (Sandbox Code Playgroud)
如果我删除无参数构造函数,则在应显示控件时会出现 NullReferenceException 异常。当存在无参数构造函数时,不会执行显示内容的代码。
我的问题是如何强制 WPF 使用参数执行构造函数?我不想删除无参数构造函数,因为这样我就在 VisualStudio 中丢失了设计器。
public partial class RemindersListing : UserControl
{
private readonly IReminderReadLogic _reminderReadLogic;
public ObservableCollection<Reminder> Reminders { get; set; }
public RemindersListing()
{
}
public RemindersListing(IReminderReadLogic reminderReadLogic)
{
_reminderReadLogic = reminderReadLogic;
InitializeComponent();
var list = _reminderReadLogic.Get();
Reminders = new ObservableCollection<Reminder>(list);
}
}
Run Code Online (Sandbox Code Playgroud) 当我在服务器资源管理器中通过Visual Studio检查Windows Azure存储表内容时,我对这个日期处于混乱状态印象深刻.
什么是Windows Azure存储的默认顺序?我需要有关订单和方向的信息.