ASP.Net实体框架(ASP.Net Entity Framework)
我只是尝试使用ASP.Net实体框架,这是我第一次尝试使用ORM框架,因此忍受着我如果我吠叫错误的树。
为了简化这个问题,我得到了以下两张表格
日历
CalendarID用户标识日期事件名称
用户
UserId用户名
我已经将它们添加到我的实体框架模型中,并建立了表之间的链接。 然后,我可以通过使用类似的东西来显示我的MVC视图中的日历列表
<%= calendarEntry.DateAdded%> 但是,如果我然后尝试使用
> <%= calendarEntry.Users.Username%>:<%= calendarEntry.DataAdded%> 它调用了calendarEntry.Users,因为它说它是空的。 为什么实体框架不通过使用细节? 我需要在模型设计器中更改某些内容吗?
如果它有助于将数据发送到视图的MVC控制器中的代码就像这样
var Entities = new UnityGamersEntities(); 返回查看(Entities.Calendar);
真的希望这是有道理的。
I'm just trying the ASP.Net Entity framework its the first time I've tried to use an ORM framework so bear with me If I'm barking up the wrong tree.
To simplify the problem I've got the following 2 tables
Calendar
CalendarID UserID Date EventName
Users
UserId Username
I've added them both to my Entity Framework model and its established the link between the tables. I'm able to then display a list of Calendars from my MVC view, by using something like
<%= calendarEntry.DateAdded%> However if I then try to use
><%= calendarEntry.Users.Username%> : <%= calendarEntry.DataAdded%> It falls over on the call to calendarEntry.Users as it says it is null. Why is the entity framework not pulling through the use details? Do I need to change something in my model designer?
If it helps the code in the MVC controller that sends the data to the view is like this
var Entities = new UnityGamersEntities(); return View(Entities.Calendar);
Really hope that makes sense.
原文:https://stackoverflow.com/questions/551549
最满意答案
正如@ThiefMaster所提到的,您可以使用子进程模块 ,它提供
poll
(检查进程是否终止)和communicate
方法(将数据发送到子进程stdin)。这些方面的东西:
# Starts encoding in a subprocess proc = subprocess.Popen(['ffmpeg', '-i' 'myinput', 'myoutput']) duration = 3 sleeptime = 0 while proc.poll() is None and sleeptime < 3: # Wait for the specific duration or for the process to finish sleep(1) sleeptime += 1 # If process is not terminated if proc.poll() is None: # Cancels process, waits for it to complete proc.communicate("q")
如果尚未在指定的
duration
内完成,则将取消子进程。As @ThiefMaster mentioned, you can use the subprocess module, which provides both
poll
(to check whether the process is terminated) and acommunicate
method (to send data to the subprocess stdin).Something along these lines:
# Starts encoding in a subprocess proc = subprocess.Popen(['ffmpeg', '-i' 'myinput', 'myoutput']) duration = 3 sleeptime = 0 while proc.poll() is None and sleeptime < 3: # Wait for the specific duration or for the process to finish sleep(1) sleeptime += 1 # If process is not terminated if proc.poll() is None: # Cancels process, waits for it to complete proc.communicate("q")
Will cancel the subprocess if it has not finished within the specified
duration
.
相关问答
更多-
发生事件时从处理程序中删除回调并发布新的runnable。 像这样的东西应该工作: protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); handler = new Handler(); post ...
-
你需要注意fork的返回值。 对代码的这种小修改可能会满足您的需求。 #include
#include #include #include struct process{ int pid; int bt; }; int main() { int no_of_process,i,new_process; printf("Enter the number of process\n"); ... -
由于PROCESS_INFORMATION pif包含DWORD dwProcessId新创建的进程的id,因此您可以通过将每个pif.dwProcessId添加到std::vector
processIds来创建自己的列表。 要终止创建的进程,只需执行类似的操作即可 for (auto processId : processIds) { TerminateMyProcess(processId, 1); } 编辑: 我想我刚刚使用#include std:: ... -
如何存储1个月的持续时间并终止它以获取安装文件(How to store 1 month duration period and terminate it for setup file)[2022-02-19]
在IDE的“注册表”视图中创建一个注册表项,并在安装项目中为其提供值。 像这儿 但要测试值,例如,如果粘贴了一个月,最好在应用程序的启动过程中对此进行测试,如果时间过期则关闭它。 另外为了防止有人把时间花在他的机器上,我会在每次应用程序启动时添加检查,只记录当天的剩余时间,然后编写逻辑以防止滥用 Create a registry item in the Registry view in the IDE and give it the value in the setup project. Like her ... -
正如@ThiefMaster所提到的,您可以使用子进程模块 ,它提供poll (检查进程是否终止)和communicate方法(将数据发送到子进程stdin)。 这些方面的东西: # Starts encoding in a subprocess proc = subprocess.Popen(['ffmpeg', '-i' 'myinput', 'myoutput']) duration = 3 sleeptime = 0 while proc.poll() is None and sleeptime ...
-
尝试转换类型 elapsed/time.Duration(totalPixels) 要么 int(elapsed)/totalPixels Try convert type elapsed/time.Duration(totalPixels) or int(elapsed)/totalPixels
-
C# - 具有特定持续时间的TcpClient异步连接(C# - TcpClient asynchronous connection with specific time duration)[2022-06-16]
添加另一个延迟任务,然后使用返回第一个完成任务的Task.WhenAny 。 通过将完成的任务与客户端任务进行比较,您将“决定”首先完成哪项任务 public async TaskIsConnected() { using (TcpClient client = new TcpClient()) { var clientTask = client.ConnectAsync(ipAddress, port); var delayTask = Ta ... -
真正的解决方案是处理原因而不是症状: 症状: run函数永远不会结束 原因:通信请求永远不会结束 大多数通信(输入)功能是可中断的,或具有本机超时。 如果您的通信例程没有本机超时,您可以(可能)使用alarm Posix调用将它们包装起来,该调用应该干净地中断它们并允许运行功能干净地退出。 您只需要注意alarm使用信号的情况,因此您不能阻止SIG_ALRM ,但您可以使用它来安装存储已被调用的地方的信号处理程序。 恕我直言,它将比使用std::terminate直接终止程序更简单,更清晰,更好地分离关注点 ...
-
尝试使用ffmpeg中的setpts过滤器。 从过滤器文档 : 应用慢动作效果: setpts = 2.0 * PTS 你想要的东西大约长10倍: ffmpeg -i input -vf setpts=10*PTS output ffmpeg将复制帧以实现新的持续时间。 对于那些想要对音频执行相同操作的人,请参阅asetpts过滤器。 我假设你想在MP4容器中使用H.264,因为你没有指出你想要的输出格式: ffmpeg -i input -vf setpts=10*PTS -c:v libx264 -p ...
-
如何确定持续时间(How can I determine a time duration)[2022-08-10]
如果没有样本开始数据,很难说,但我同意@Kevin - 您的查询可以从一开始就简化。 特别是,您的查询正在执行它不需要的大量工作,它通常会丢弃。 此查询进行以下假设: 所有段都有Out时间,每个只有一个 。 Out时间总是晚于In time。 SegmentNumber对于所有输入/输出对都是正确的(尽管可以在必要时生成)。 您应该可以使用接近以下内容的内容: SELECT NEWID() AS Indx, @Indx_Road AS Indx_Road, @Indx_User AS Indx ...