我有一个关于EF和WCF的架构问题.我们正在使用Entity Framework(带有Oracle数据库)和基于WPF的GUI开发三层应用程序.GUI通过WCF与服务器通信.
我们的数据模型非常复杂(超过一百个表),有很多关系.我们目前正在使用默认的EF代码生成模板,我们在跟踪实体状态方面遇到了很多麻烦.
客户端上的用户界面也相当复杂,有时将具有超过50个对象的对象图向下发送到单个用户界面,在实体之间具有多个聚合层.能够在BLL层中轻松决定在客户端上修改了哪些对象以及新创建了哪些对象是一个重要的目标.
在两层之间管理实体和实体状态最明智的方法是什么?自我跟踪实体?这种情况下最常见的陷阱是什么?
那些在真实生产环境中使用STE的人能说出他们的经历吗?
我正在使用Microsoft提供的TiltEffect工具.我试图将它与TextBlocks一起使用,但是,即使我将TextBlock类型添加到Tiltable项列表中,它也不起作用:
TiltEffect.TiltableItems.Add( typeof( System.Windows.Controls.TextBlock ) );
Run Code Online (Sandbox Code Playgroud)
但是,如果我用边框包围TextBlock ,并将Tap事件移动到Border,它可以正常工作.
这种行为有什么具体原因吗?用Borders包围我所有可点击的TextBlocks并不太优雅.
更新:这同样适用于矩形形状.
UPDATE2:我当前的解决方案是一种解决方法,我定义了一个自定义控件:
<UserControl x:Class="MyApp.Controls.TiltableTextBlock"
Name="tiltableTextBlock"
...>
<Button Margin="0" Padding="0">
<Button.Template>
<ControlTemplate>
<TextBlock Margin="0" Padding="0"
Text="{Binding Text, ElementName=tiltableTextBlock}"
Style="{Binding Style, ElementName=tiltableTextBlock}" />
</ControlTemplate>
</Button.Template>
</Button>
</UserControl>
Run Code Online (Sandbox Code Playgroud)
并在代码背后:
public partial class TiltableTextBlock : UserControl
{
public TiltableTextBlock()
{
InitializeComponent();
}
public string Text
{
get { return (string)GetValue( TextProperty ); }
set { SetValue( TextProperty, value ); }
}
public static readonly DependencyProperty TextProperty =
DependencyProperty.Register( "Text", …Run Code Online (Sandbox Code Playgroud) 我想在 Google Cloud Storage 中创建域名存储桶。
我验证了域的所有权,现在我可以使用我自己的帐户创建具有特定名称的存储桶。
但是,我还需要向其他一些开发人员和一些服务帐户授予权限以执行相同的操作,因此我将这些用户添加为经过验证的域所有者。
它们可以在用户屏幕上看到。
以及关于域名所有者的页面。
但是,如果我尝试使用任何添加的帐户(无论是真人帐户还是服务帐户)创建域名存储桶,我都会收到以下错误。
10:46:35.447 Creating gs://bucket.mydomain.com/...
10:46:35.697 AccessDeniedException: 403 The bucket you tried to create is a domain name owned by another user.
Run Code Online (Sandbox Code Playgroud)
(如果我尝试从 Web 管理控制台创建存储桶,我会收到类似的错误。)
我验证了这些帐户具有 GCE 项目的权限,因此只要它们不是域名,它们就可以很好地创建存储桶。
我究竟做错了什么?
在我的扩展中,我在资源管理器视图的栏上有一些按钮:
如何指定按钮出现的顺序?
我尝试更改属性中package.json命令的顺序commands:
"commands": [
{
"command": "codeFragments.exportFragments",
"title": "Export all fragments to Json",
"icon": {
"light": "images/icon-export-light.png",
"dark": "images/icon-export-dark.png"
}
},
{
"command": "codeFragments.importFragments",
"title": "Import fragments from Json",
"icon": {
"light": "images/icon-import-light.png",
"dark": "images/icon-import-dark.png"
}
},
{
"command": "codeFragments.deleteAllFragments",
"title": "Delete all fragments",
"icon": {
"light": "images/icon-delete-light.png",
"dark": "images/icon-delete-dark.png"
}
}
],
Run Code Online (Sandbox Code Playgroud)
还尝试在我在view/title属性中指定 UI 的部分重新排序:
"view/title": [
{
"command": "codeFragments.exportFragments",
"when": "view == codeFragments",
"group": "navigation"
},
{
"command": "codeFragments.importFragments",
"when": "view …Run Code Online (Sandbox Code Playgroud) 高级单元测试和模拟对象的值已经讨论过类似的主题
但是,我想描述一下具体情况,并询问您对我应该如何编写单元测试的意见.
我正在开发一个使用Entity Framework的普通3层应用程序.在EF之上,我有两层:
没有进一步的描述,这里是我想编写单元测试的类:
public class PersonManager
{
private IPersonRepository personRepository; // This is injected.
// Constructor for injection is here.
public void ComplexMethod()
{
// High level business logic
bool result = this.SimpleMethod1();
if(result)
this.SimpleMethod2(1);
else
this.SimpleMethod2(2);
}
public bool SimpleMethod1()
{
// Doing some low-level work with the repository.
}
public void SimpleMethod2(int param)
{
// Doing some low-level work with the repository.
}
}
Run Code Online (Sandbox Code Playgroud)
单元测试真的很容易,SimpleMethod1并SimpleMethod2通过PersonManager …
关于这个主题已经存在一些问题(例如实体框架中的Expression.Invoke?),但是,我无法找到适合我具体情况的答案.我想定义一个这样的方法:
public IQueryable<Customer> GetCustomers(Expression<Func<Customer, bool>> condition)
{
return from p in ctx.Customers.AsExpandable()
where condition.Compile()(p)
select p;
}
Run Code Online (Sandbox Code Playgroud)
AsExpandable方法来自LinqKit(正如前面提到的线程中所建议的那样).但是,当我尝试像他的方式调用我的方法时:
var customers = GetCustomers(c => c.ID == 1);
Run Code Online (Sandbox Code Playgroud)
它抛出InvalidCastException:
无法将类型为"System.Linq.Expressions.InstanceMethodCallExpressionN"的对象强制转换为"System.Linq.Expressions.LambdaExpression".我究竟做错了什么?
如果我们要求MVC框架为我们生成URL,例如通过UrlHelper在控制器内部使用,生成的URL中的路由段将是大写的.
[Route("[controller]")]
public class PeopleController : Controller
{
[HttpGet]
public IActionResult Get()
{
var url = this.Url.Action("Get", "People"); // Returns "/People"
...
}
}
Run Code Online (Sandbox Code Playgroud)
如何告诉MVC生成小写路由,所以在上面的例子中,返回"/ people"?
我正在开发一个应用程序,其核心代码库将是Windows,iOS和Android的跨平台.
我的问题是:我应该如何在内部表示此应用程序使用的字符串,以便能够在所有三个平台上有效地使用它们?
值得注意的是,我在Windows中大量使用DirectWrite,其中API函数通常期望传递wchar_t*(顺便说一句,API文档声明"指向Unicode字符数组的指针.",我不是知道这是否意味着它们是否采用UTF-16编码)
我看到了三种不同的方法(但是我发现很难掌握使用C++以跨平台方式处理Unicode字符串的细节,所以也许我会错过一些重要的概念):
什么是最好的解决方案?顺便说一句,是否有任何现有的跨平台库抽象字符串处理?(以及读取和序列化Unicode字符串)
(更新:删除了有关char*和std :: string差异的问题的部分.)
我们已经开始在 ASP.NET 应用程序中使用WinHttpHandler NuGet 包。在开发机器上它运行良好,也适用于我们的登台环境。该应用程序面向 .NET 4.6.1。
但是,在生产中它会引发以下错误:
System.DllNotFoundException: Unable to load DLL 'api-ms-win-core-localization-l1-2-0.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
Run Code Online (Sandbox Code Playgroud)
我在谷歌上搜索了很多关于这个问题的信息,但找不到关于这个 dll 的任何有意义的信息。(我在论坛中发现有些人在遇到类似问题时手动将 dll 复制到他们的生产服务器,但这似乎不是正确的解决方案。)
这个dll来自哪里?应该明确安装吗?
(在我的开发机器上,我在 中找到了它C:\Windows\System32,在我们的登台机器上它在 中C:\Windows\System32\downlevel,但我不知道它来自哪里。)
在 .NET Core 上,使用System.Net.Http.HttpClient,先调用response.Content.ReadAsStringAsync(),然后调用是否安全response.Content.ReadAsStreamAsync()?
例如,做这样的事情。
var response = await client.GetAsync("http://example.com");
var respStr = await response.Content.ReadAsStringAsync();
// ... Do something with the string
var respStream = await response.Content.ReadAsStreamAsync();
// ... Do something with the stream
Run Code Online (Sandbox Code Playgroud)
我担心响应内容会被传输,因此无法阅读两次。
我已经用几个请求对其进行了测试,它总是对我有用,但它能保证有效吗?
我有以下类层次结构:
class IControl
{
virtual void SomeMethod() = 0; // Just to make IControl polymorphic.
};
class ControlBase
{
public:
virtual int GetType() = 0;
};
class ControlImpl : public ControlBase, public IControl
{
public:
virtual void SomeMethod() { }
virtual int GetType()
{
return 1;
}
};
Run Code Online (Sandbox Code Playgroud)
我有一个IControl抽象类和一个ControlBase类.ControlBase类不从IControl继承,但我知道每个IControl实现都将从ControlBase派生.
我有以下测试代码,其中我使用dynamic_cast和C样式转换将IControl -reference转换为ControlBase(因为我知道它是从它派生的):
int main()
{
ControlImpl stb;
IControl& control = stb;
ControlBase& testCB1 = dynamic_cast<ControlBase&>(control);
ControlBase& testCB2 = (ControlBase&)control;
ControlBase* …Run Code Online (Sandbox Code Playgroud) c# ×6
.net ×2
asp.net ×2
c++ ×2
.net-core ×1
android ×1
architecture ×1
casting ×1
directx ×1
dll ×1
dns ×1
inheritance ×1
ios ×1
linq ×1
linqkit ×1
mocking ×1
polymorphism ×1
security ×1
typescript ×1
unit-testing ×1
windows ×1