是否可以使用实体框架调用表值函数(TVF)?
我在我的数据库中定义了三个TVF,它们没有显示在Entity Framework的模型中,也没有显示在"从数据库更新模型"向导中.
在Linq-to-SQL中很容易做到这一点,你只需将TVF拖到设计图面上,但在L2E中看起来似乎不太可能.
到目前为止,我还没有找到任何甚至一起提到TVF和实体框架的内容.
我正在使用OS X上的Mono在C#中编写一个控制台应用程序.
在Windows上,以下是将文本复制到剪贴板的方法:
Clipboard.SetText("text");
Run Code Online (Sandbox Code Playgroud)
...从标记有STAThread属性的方法:
[STAThread] // for OLE
public static void Main (string[] args)
{
Clipboard.SetText("text");
}
Run Code Online (Sandbox Code Playgroud)
剪贴板在System.Windows.Forms中定义.该代码在Windows 上的官方Microsoft .NET运行时和 OS X上的Mono运行时下编译和运行.
在Windows上,文本被复制,因此不存在忘记引用或using语句的问题.
不幸的是,当我在Mono/OS X下运行代码时,文本实际上并未复制到剪贴板.我的Dock上出现了一些快速的东西然后消失得很快,但不管怎样,我正在尝试复制的文本不会最终放在剪贴板上.
那么:我如何复制文本使用Mono在OS X(和Linux?)上做剪贴板?
如果您对查看整个项目感兴趣,请访问以下代码:https://github.com/leeohsheeus/boom-sharp.
我正在使用ASP.NET Web API和Ninject组建一个REST服务,但我怀疑这可能是一个比IoC框架更具体的IoC问题.我有许多对象需要访问用户实体的简单缓存:
public class UserCache
{
private IList<User> users;
private IUserRepositoryFactory factory;
[Inject]
public UserCache(IUserRepositoryFactory factory)
{
this.factory = factory;
this.users = new List<User>();
}
public void Add(int id)
{
IUserRepository repo = factory.Create(new TestContext());
this.users.Add(repo.Get(id));
}
public int Count { get { return this.users.Count; } }
}
Run Code Online (Sandbox Code Playgroud)
在实践中,缓存是直读的,并且将使用UserRepository(和关联的IUserRepository接口)填充用户实体:
public class UserRepository : IUserRepository
{
private readonly TestContext context;
public UserRepository(TestContext context)
{
this.context = context;
}
public User Get(int id)
{
return new User() { Name = "Test …Run Code Online (Sandbox Code Playgroud)