这是声明实体框架上下文的最佳实践
function()
{
DBContext context = new DBContext();
//Entity code
return ;
}
Run Code Online (Sandbox Code Playgroud)
要么
function()
{
using(DBContext context = new DBContext())
{
//Entity code
}
}
Run Code Online (Sandbox Code Playgroud)
我们是否需要在EntityFrameWork中使用?如果是,我的第二个问题
在DataAccess Layer中我执行EF并将结果存储在IEnumerable里面使用
我的DL
function()
{
IEnumerable something = null;
using(DBContext context = new DBContext())
{
IEnumerable something = ....
}
return something;
}
Run Code Online (Sandbox Code Playgroud)
在控制器中
function()
{
List some = something.ToList();
}
Run Code Online (Sandbox Code Playgroud)
在我的控制器中我得到这个列表,因为我需要做一些查找操作
"The operation cannot be completed because the DbContext has been disposed Entity Framework"
Run Code Online (Sandbox Code Playgroud)
是的我可以从DL返回一个列表,它工作正常
如果我使用IEnumerable,我该如何处理?
我在带有XAML页面的PCL中使用Xamarin.Forms.我想出的控制样式的唯一方法是使用内联语法.
<Button Text="Inquiry" TextColor="Blue" />
Run Code Online (Sandbox Code Playgroud)
我更喜欢使用像这样的结构:
<Page.Resources>
<Style TargetType="Button">
<Setter Property="BorderThickness" Value="5" />
<Setter Property="Foreground" Value="Blue" />
</Style>
</Page.Resources>
Run Code Online (Sandbox Code Playgroud)
(http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh465381.aspx)
但是,尚未支持Style元素.有没有人成功地将布局与内容分开?
仅供参考:我也在Xamarin论坛上发布了这个问题,所以任何通过谷歌到这里的人都可能想查看这个页面:http://forums.xamarin.com/discussion/19287/styling-of-xamarin-xaml #最新
我正在寻找一种方法来使用RoleEnviroment类或类似的东西从C#代码获取云服务的部署名称,以便在myservice.cloudapp.net我得到的情况下部署我的服务myservice.
我怎样才能做到这一点?
服务
Public Class GetContactConsumer
Implements Consumes(Of Schema.KlantService.IGetContactV1).Context
Public Sub Consume(message As IConsumeContext(Of Schema.KlantService.IGetContactRequestV1)) Implements MassTransit.Consumes(Of IConsumeContext(Of Schema.KlantService.IGetContactRequestV1)).All.Consume
HandleMessageAsync(message)
End Sub
Private Async Sub HandleMessageAsync(context As IConsumeContext(Of Schema.KlantService.IGetContactPersonenRequestV1))
Dim Id = context.Message.Id
Dim contacten = Await New ContactPersonenController().GetContactPersonen(Id)
Dim response As New GetContactResponseV1
response.Contacten = contacten
context.Respond(response)
End Sub
End Class
Run Code Online (Sandbox Code Playgroud)
MassTransit支持请求回复机制,但困扰我的是响应者的设计取决于它.我已设置此服务以支持RR,但是如果我想从其他服务发送内容(使用基于正常事件的练习).将此设置与消费者结合使用以进行响应,响应将最终出现在错误队列中.
我的猜测是,这是因为我的消费者发送的ACK不足.有没有办法可以在MVC应用程序中使用请求回复,但是使用常规事件进行服务到服务通信?
Xamarin Forms具有以下App类:
public class App : Application
{
public App()
{
// The root page of your application
MainPage = new ContentPage
{
Content = new StackLayout
{
VerticalOptions = LayoutOptions.Center,
Children = {
new Label {
XAlign = TextAlignment.Center,
Text = "Welcome to Xamarin Forms!"
}
}
}
};
}
protected override void OnStart()
{
// Handle when your app starts
}
protected override void OnSleep()
{
// Handle when your app sleeps
}
protected override void OnResume()
{ …Run Code Online (Sandbox Code Playgroud) 我们必须使用C#为我们的ASP.NET客户端构建一个事件注册网站.其中一个要求是客户希望使用en excel文件自己将新的外语添加到他的网站.我知道如何在Visual Studio中使网站多语言,但我不知道如何在代码中基于excel文件生成资源文件.我还注意到VS生成了一个名为Resource.en.designer.cs的第二个文件,但我找不到任何文档如何生成该文件.
顺便说一句,最终用户与IT有关.(显然)他知道自己在excel周围的方式.
任何帮助表示赞赏!
Yoeri
编辑:!Robert Levy提供了一个很好的方法!如何:
第1步:读取excel文件(使用OleDBAdapter对我来说是最好的方法,因为你可以使用列标题等)以这种格式将语言写入txt文件:KEY = TRANSLATION没有空格或其他任何内容
第2步:在您的计算机上找到ResGen.exe(它随Visual Studio一起提供,所以看起来像c:\ program files\visual studio\sdk ...但是我发现它@ C:\ Program Files(x86)\ Microsoft SDKs \的Windows\v7.0A\BIN\ResGen.exe)
第3步:
使用Process.Start("resgen.exe")提示调用exe :使用ProcesStartInfo进行简单的参数和首选项设置
(第4步:)
将文件移动到所需位置(我发现App_GlobalResources工作正常)
第5步:
将用户currentUIculture设置为您想要的文化!
我有一个Skeleton skeleton来自这个SkeletonFrameReady活动.而且我有一个在窗户上绘制骷髅的功能,
void DrawSkeleton(Skeleton s),
Run Code Online (Sandbox Code Playgroud)
它以Skeleton作为输入,并将骨架的2D图像绘制到我的窗口.
现在,我想改变右手的x和y值,并使用相同的函数在窗口上绘制它void DrawSkeleton(Skeleton s).
但是,当我尝试做类似的事情时:
skeleton.Joints[JointType.HandRight].Position.X = 3;
Run Code Online (Sandbox Code Playgroud)
它不允许我这样做:
无法修改'Microsoft.Kinect.Joint.Position'的返回值,因为它不是变量.
这可能是因为Position它不是一个变量,是一个属性.
题:
如何复制Skeleton对象并更改该对象上Position的Joints 值.
我正在为我的角度应用完成测试台.但是在业力 - 茉莉花测试中存在一个问题,它会引发错误
抛出[object ErrorEvent]
我更新了node_modules作为我在以下链接中找到的解决方案 如何在我的Karma/Jasmine测试中调试"[object ErrorEvent] thrown"错误?
但现在错误随机出现,有时候测试床没有任何故障,有时会出现错误触发.有任何建议可以永久避免它吗?
PS - 如果您需要更多资源,请在评论中告诉我.谢谢!
SomeComponent.spec.ts
import { RouterTestingModule } from '@angular/router/testing';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { NgModule } from '@angular/core';
import { HttpClient, HttpClientModule } from '@angular/common/http';
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { SomeComponent } from './some.component';
import { HttpLoaderFactory } from '../app.module';
import { AppRoutingModule } from '../app-routing.module';
import …Run Code Online (Sandbox Code Playgroud) 我有一个非常好的owin文化中间件.
它只是根据网址改变文化.这完全适用于4.5.*.现在当runtiome更改为4.6.1时,文化不再保留,因此它不起作用.
我可以在一个非常简单的解决方案中重现它,只有这个中间件模拟文化变化
public class CultureMiddleware : OwinMiddleware
{
public CultureMiddleware(OwinMiddleware next)
: base(next)
{
}
public override async Task Invoke(IOwinContext context)
{
var culture = new CultureInfo("es-ES");
Thread.CurrentThread.CurrentCulture = culture;
Thread.CurrentThread.CurrentUICulture = culture;
CultureInfo.CurrentCulture = culture;
CultureInfo.CurrentUICulture = culture;
await Next.Invoke(context);
}
}
Run Code Online (Sandbox Code Playgroud)
我将中间件附加到它执行的管道但是当我调用一个动作时,控制器没有文化(就像在.net 4.5.1中那样)
我已经在这里发布了,但支持非常慢.每两周一次回答然后看起来他们没有尝试过他们写的东西:-(
https://connect.microsoft.com/VisualStudio/feedback/details/2455357
我正在建立一个使用Angular Material Autocomplete模块的表单。我从服务器加载选项,并使用输入过滤它们。效果很好,现在我想添加一个“清除”图标,以在需要时清除该字段。
clear选项将清除该字段,但不会再次显示自动完成选项。当我手动删除带有退格但不带有图标的输入内容时,它将显示它们。
为了“清除”该字段,我使用以下代码:
clear(control: string): void {
this.form.get(control).setValue('');
}
Run Code Online (Sandbox Code Playgroud)
我从一个mat-icon组件中调用它:
<mat-form-field>
<input matInput type="text" ... >
<mat-icon matSuffix (click)="clear(fieldName)" ...>
clear</mat-icon>
</mat-form-field>
<mat-autocomplete> ... </mat-autocomplete>
Run Code Online (Sandbox Code Playgroud)
其中fieldName(字符串)是我要清除的控件的名称。
这就是我过滤自动填充选项的方式:
this.filter = this.form.get(field).valueChanges.pipe(
startWith(''), // Don't even know what this does...
map(value => this.options.filter(option => option.name.toLowerCase().includes(value.toString().toLowerCase())))
);
Run Code Online (Sandbox Code Playgroud)
我怀疑方法setValue('')内部可能有错误clear()。或者也许是我正在使用的过滤方法。
这是StackBlitz中的完整示例:
https://stackblitz.com/edit/angular-autocomplete-clear9zzmw2
我正在寻找C#(.net框架)中的数据结构,我可以使用它按排序顺序添加数据(而不是添加所有数据,然后应用排序).我的数据是对象,我想根据某个字段(整数字段)添加它们.
谢谢
当倒计时到达0时,我想关闭并创建一个新的div.我的div看起来像这样
<div id="bij2">Test
<div id="bij2Blauw">
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3" class="titel">Resterende tijd</td>
</tr>
<tr>
<td height="25" colspan="3" align="center" valign="middle">
<input id="aktie2" type="text" class="countdownTekst" size="27" readonly="readonly">
<script language="javascript">
countdown(2012, 7, 29, 'aktie2', 'bij2')
</script>
</td>
</tr>
<tr>
<td height="60">
<input name="kopen1" type="submit" class="kopen" id="kopen1" value="Koop nu"
/>
</td>
<td height="60" colspan="2" align="right" valign="bottom">
<span class="euro">€</span>
<span class="prijs">14,95</span>
</td>
</tr>
</table>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
这是倒计时
function countdown(yr, m, d, idCountdown, divId) {
var theyear = yr;
var themonth = …Run Code Online (Sandbox Code Playgroud) c# ×7
.net ×4
angular ×2
xamarin ×2
.net-4.6 ×1
asp.net-mvc ×1
azure ×1
cultureinfo ×1
dynamic ×1
html ×1
javascript ×1
kinect ×1
localization ×1
masstransit ×1
owin ×1
rabbitmq ×1
razor ×1
sorting ×1
testbed ×1
testing ×1
xaml ×1