我使用Nhibernate 2.1.2.4000 GA与Nhibernate.Linq 1.0和最新版本的FluentNhibernate从github上的master下载.
我正在做一些测试,每当我尝试删除由linq查询检索的实体时,我收到此错误:
没有持久性:NHibernate.Linq.Query`1 [[Employees.Core.Entities.Employee,Employees.Core,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null]]
所有其他操作(插入,更新和选择)看起来很好;
我的实体类:
public class Employee
{
public Employee()
{
}
public virtual Int32 Id { get; private set; }
public virtual String Name { get; set; }
public virtual String SayHello()
{
return String.Format("'Hello World!', said {0}.", Name);
}
}
Run Code Online (Sandbox Code Playgroud)
映射类:
public class EmployeeMap : ClassMap<Employee>
{
public EmployeeMap()
{
Id(x => x.Id);
Map(x => x.Name)
.Not.Nullable()
.Length(50);
}
}
Run Code Online (Sandbox Code Playgroud)
组态:
Assembly mappingsAssemly = Assembly.GetExecutingAssembly();
return Fluently.Configure() …Run Code Online (Sandbox Code Playgroud) 我正在使用EF 4.3和Code第一种方法.
对于EF 4.3,它建议使用新的<entityFramework />配置部分来初始化上下文的连接字符串.
我已经在线进行了一些搜索,我似乎无法找到一种方便的方法来使用此方法初始化具有可配置数据库名称的连接.
例如,假设MyDBContext我的应用程序中有一个实体.我希望它使用连接字符串中指定的数据库名称Initial Catalog=MyDB;
使用EF 4.1中的旧方法,我可以通过将连接字符串添加到<connectionstring>配置文件中的部分来做到这一点.
<add name="MyDBContext" connectionString="Data Source=.\SQLEXPRESS; Initial Catalog=MyDB; Integrated Security=True; MultipleActiveResultSets=True" providerName="System.Data.SqlClient"/>
Run Code Online (Sandbox Code Playgroud)
如果我想使用EF 4.3支持的更新的配置部分,我无法在连接字符串中指定数据库名称.我尝试了以下但Initial Catalog属性被忽略.我认为它有充分的理由被忽略了,因为DefaultConnectionFactory在我的应用程序中,整个事物可以被多个上下文使用
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
<parameters>
<parameter value="Data Source=.\SQLEXPRESS; Initial Catalog=MyDB; Integrated Security=True; MultipleActiveResultSets=True" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
Run Code Online (Sandbox Code Playgroud)
我的codefirst方法因使用它而创建的默认数据库名称是 MyNamespace.MyDBContext
我知道有一种方法可以通过将值传递给nameOrConnectionString基础DBContext对象上的参数来覆盖此默认命名.
所以我可以这样做:
public MyDBContext() : base("MyDB") { }
Run Code Online (Sandbox Code Playgroud)
但是,如果我采用这种方法,我最终将数据库名称硬编码到我的应用程序中,我个人不喜欢这样.
我想知道有没有办法可以方便地从Web.config文件中传递数据库名称的数据库名称,还是应该继续使用该<connectionstrings>部分?
我想在代码隐藏中通过BoxView组件添加文本AbsoluteLayout。
像这样的东西:
我该怎么做?
这里是我的代码,在那里我把AbsoluteLayout到StackLayout结尾:
public TestPageBoxView()
{
StackLayout sl = new StackLayout();
AbsoluteLayout al = new AbsoluteLayout();
BoxView bv = new BoxView { BackgroundColor = Color.Green };
Label l = new Label { Text = "Some text with \n breaks" };
AbsoluteLayout.SetLayoutBounds(l, new Rectangle(0, 0,1,1));
AbsoluteLayout.SetLayoutFlags(l, AbsoluteLayoutFlags.All);
sl.Children.Add(bv);
sl.Children.Add(al);
Content = sl;
}
Run Code Online (Sandbox Code Playgroud)
所以,我担心的是这个l组件被坚持到 stacklayout 而不是 BoxView。
也许我应该试试RelativeLayout?
你知道 git 上的一些组件吗?喜欢 XLabs?
谢谢。
我正在尝试使用ffmpeg创建视频马赛克.我的完整命令看起来像这样 -
ffmpeg -i rtmp://localhost:1935/live/output1 -i rtmp://localhost:1935/live/output2 -i rtmp://localhost:1935/live/output3 -i rtmp://localhost:1935/live/output4 -filter_complex "nullsrc=size=640x480 [base]; [0:v] setpts=PTS-STARTPTS, scale=320x240 [upperleft]; [1:v] setpts=PTS-STARTPTS, scale=320x240 [upperright]; [2:v] setpts=PTS-STARTPTS, scale=320x240 [lowerleft]; [3:v] setpts=PTS-STARTPTS, scale=320x240 [lowerright]; [base][upperleft] overlay=shortest=0 [tmp1]; [tmp1][upperright] overlay=shortest=0:x=320 [tmp2]; [tmp2][lowerleft] overlay=shortest=0:y=240 [tmp3]; [tmp3][lowerright] overlay=shortest=0:x=320:y=240" -filter_complex amix=inputs=4:duration=longest -c:a aac -strict -2 -ar 44100 -c:v libx264 -f flv rtmp://localhost:1935/live/myStream
Run Code Online (Sandbox Code Playgroud)
只要所有4个输入流都在运行,这种方法就可以正常工作.但是说其中一个流下降了一段时间并重新上线.输出继续显示此流被卡住(暂停).因为一旦流下降(AVERROR_EOF)ffmpeg停止尝试从输入流中获取更多数据包.我必须重新启动ffmpeg进程才能恢复所有工作.
有没有办法在这里添加重试逻辑,只要进程处于活动状态,就会告诉ffmpeg继续尝试处理所有输入源?
我有一个使用现有数据库的应用程序,目前使用NHibernate作为O/R-Mapper.
现在,我需要使用Code First和Fluent API Configuration迁移到Entity Framework 6.1.1.
但是现在我对部分数据模型有问题,因为它使用不同类型的继承策略(TPT和TPH)
注意:在这里发布完整的数据模型对我来说似乎有点太大了,所以我在一个小的POC程序中重现了我面临的问题.
CLASS | TABLE | TYPE
-----------------------+--------------------+------
BaseEntity (abstract) | BaseTable |
Inherited_TPH | BaseTable | 1
Inherited_TPT | Inherited_TPT | 2
Run Code Online (Sandbox Code Playgroud)
调用表中用作描述符的列 Type
根据这个答案,我添加了一个抽象类Intermediate_TPH作为中间层:

一些示例数据:带有ID=3类型的条目Inherited_TPT

这些是我的实体类和我的上下文类:
class MyContext : DbContext
{
public MyContext ( string connectionString )
: base ( connectionString )
{
}
public DbSet<Inherited_TPH> TPH_Set { get; set; }
public DbSet<Inherited_TPT> …Run Code Online (Sandbox Code Playgroud) c# inheritance entity-framework ef-code-first entity-framework-6
我正在使用Cordova开发一个跨平台的移动应用程序.我有一个带有表格的HTML页面.add row点击时我有一个按钮向我的表添加一个新行.我需要一个类似iOS的滑动操作才能执行删除操作.我使用touchstartevent来刷我表中的静态行.这工作正常但不是动态创建的表行.怎么做这个滑动动作?
这是我到目前为止的代码:
HTML
<div class="fortable">
<table id="cashreg">
<tr>
<td class="tablecellbackground"><div class="del" id="d1" ><p>Delete</p></div><div id="cells" class="cells"><div class="denom"><p>Start Time</p></div><div class="cnt"><p>Select Item</p></div><div class="tots"><p>Employee</p></div><div class="tots1"><p>Price</p></div></div></td>
</tr>
</table>
<input type="button" class="addmore">
</div>
Run Code Online (Sandbox Code Playgroud)
JavaScript的
要向表中添加行:
$(".addmore").click(function(){
var rows = $("#cashreg tr").length+1;
$("#cashreg").append('<tr><td class="tablecellbackground"><div class="cells"><div class="denom"><p>Start Time</p></div><div class="cnt"><p>Select Item</p></div><div class="tots"><p>Employee</p></div><div class="tots1"><p>Price</p></div><div class="del"><p>Delete</p></div></div></td></tr>');
});
Run Code Online (Sandbox Code Playgroud)
对于类似iOS的滑动:
window.addEventListener('load', function(){
var el = document.getElementsByClassName('cells')[0];
ontouch(el, function(evt, dir, phase, swipetype, distance){
var touchreport = ''
touchreport += '<b>Dir:</b> ' + dir + '<br />'
touchreport += '<b>Phase:</b> …Run Code Online (Sandbox Code Playgroud) 我有2个这样的哈希集。
Hash_1 = {1, 2, 3, 4, 5}
Hash_2 = {4, 5, 6, 7, 8}
Run Code Online (Sandbox Code Playgroud)
我正在使用C#
我想比较这两个集合,并希望得到类似的输出
Hash_3 = {1, 2, 3, 6, 7, 8}
Run Code Online (Sandbox Code Playgroud) 我正在使用nHibernate无状态会话来获取对象,更新一个属性并将对象保存回数据库.
我一直收到错误消息:
无状态会话无法获取代理
我有类似的代码在其他地方工作,所以我无法弄清楚为什么这不起作用.有谁知道问题可能是什么?
我正在尝试更新该ScreenLockVersion属性.
制图:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="ApplicationUtilities"
namespace="ApplicationUtilities.Concurrency">
<class name="Screen" table="concurrency_screen" dynamic-update="true" optimistic-lock="all">
<id name="ID" column="screenID">
<generator class="identity" />
</id>
<property name="ScreenName" column="screenName" />
<property name="SubScreenName" column="subScreenName" />
<property name="ScreenLockID" column="screenLockID" />
<property name="ScreenLockVersion" column="screenLockVersion" />
<property name="ScreenLockRequired" column="screenLockRequired" />
<many-to-one name="Parent" class="Screen" column="parentScreenID" />
<many-to-one name="Identity" class="ApplicationUtilities.SystemIdentity.Identity" column="identityID" />
<many-to-one name="Application" class="ApplicationName" column="applicationID" />
<one-to-one name="LastModified" class="LastModified" property-ref="Screen" cascade="all" />
<bag name="AffectedScreens" table="concurrency_affectedScreen" cascade="all">
<key column="updatedScreenID" />
<many-to-many column="affectedScreenID" class="Screen" /> …Run Code Online (Sandbox Code Playgroud) 我正在使用ejb-2,但出现以下异常。有人可以告诉我这是什么意思吗,这可能是什么解决方案:
错误(严重):EJB异常:;嵌套的异常是:
javax.ejb.TransactionRolledbackLocalException:提交事务时出错:嵌套的异常是:
weblogic.transaction.internal.AppSetRollbackOnlyException
我想在a中插入一个超链接DataGrid并找到一个方法,以便RequestNavigate使用MVVM模式实现该行为.
到目前为止,我已经尝试了很多解决方案,但它们都没有奏效.请问你能帮帮我吗?
这是我的xaml代码:
<dgWPFCtrl:ExtDataGridTemplateColumn Header="Link to XXX" Width="*">
<dgWPFCtrl:ExtDataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock >
<Hyperlink NavigateUri="{Binding Path=ID_HTTP_LINK}"
>
<TextBlock Text="{Binding Path=ID_HTTP_LINK}"/>
<i:Interaction.Triggers>
<i:EventTrigger EventName="RequestNavigate">
<WPFCtrl:EventToCommand
PassEventArgsToCommand="True"
Command="{Binding Path=OpenLinkCommand}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Hyperlink>
</TextBlock>
</DataTemplate>
</dgWPFCtrl:ExtDataGridTemplateColumn.CellTemplate>
</dgWPFCtrl:ExtDataGridTemplateColumn>
Run Code Online (Sandbox Code Playgroud)
并遵循相对ICommand发展:
//Command for open link
RelayCommand _openLinkCommand;
public ICommand OpenLinkCommand
{
get
{
if (_openLinkCommand == null)
_openLinkCommand = new RelayCommand(param =>
{
//Command Body ...
});
return _openLinkCommand;
}
}
Run Code Online (Sandbox Code Playgroud)
哪里我错了?没想到,ICommand甚至从未打过电话!
我也尝试过使用其他类型的事件(例如MouseEnter),但没有改变!
在此先感谢您的贡献,
德比