how to change @model directive to a different model in razor view?

I have a controller that creates a model and calls a view passing the model as a parameter. In the View there is a @model directive specifying the type of Model. I want to reuse the same View, but pass a different model from the controller. Is it possible to dynamically (or conditionally) change @model directive in the View? For instance, in my controller action: var contactsModel = db.GetC

如何将@model指令更改为剃须刀视图中的不同模型?

我有一个控制器创建一个模型并调用一个视图作为参数传递模型。 在视图中有一个@model指令,用于指定模型的类型。 我想重复使用相同的视图,但从控制器传递不同的模型。 是否有可能在视图中动态(或有条件地)更改@model指令? 例如,在我的控制器操作中: var contactsModel = db.GetContacts(); var companiesModel = db.GetCompanies(); return (someCondition)? View(contactsModel):View(companiesModel); 那么如何在

Operation is not valid due to the current state of the object. in C#

I had created this method to check number of this record in the table but it gives me this error message when the value of count(*) is 0 i use this library to connect oracle db using Oracle.DataAccess.Client; private int checkPort(int portID) { int intCount = 0; try { OracleCommand oraCommand = new OracleCommand(); or

由于对象的当前状态,操作无效。 在C#中

我创建了这个方法来检查表中的这个记录的数量,但是当count(*)的值为0时,它给了我这个错误信息我使用这个库来连接oracle数据库 使用Oracle.DataAccess.Client; private int checkPort(int portID) { int intCount = 0; try { OracleCommand oraCommand = new OracleCommand(); oraCommand.Connection = new DBManager().getConnection();

To Workflow or Not to Workflow?

I am responsible for a team of developers who will are about to start development of a light weight insurance claims system. The system involves a lot of manual tasks and business workflows and we are looking at using Windows Workflow (.NET 4.0). An example of the business domain is as follows: A policy holder calls the contact centre to lodge a claim. This “event” fires two sub tasks which a

工作流程还是不工作流程?

我对将要开始开发轻量级保险索赔系统的开发团队负责。 该系统涉及大量手动任务和业务工作流程,我们正在考虑使用Windows Workflow(.NET 4.0)。 业务领域的一个例子如下:保单持有人呼叫联络中心提出索赔。 这个“事件”触发了两个并行手动操作的子任务,可能需要很长时间才能完成; 检查客户是否存在欺诈行为 - 操作员通过手动方式呼叫各种信用卡公司检查并评估欺诈客户的潜力。 从这里子任务可以输入许多子状态(检查进行

makefile:4: *** missing separator. Stop

This is my makefile: all:ll ll:ll.c gcc -c -Wall -Werror -02 c.c ll.c -o ll $@ $< clean : rm -fr ll When I try to make clean or make make , I get this error: :makefile:4: *** missing separator. Stop. How can I fix it? makefile has a very stupid relation with tabs , all actions of every rule are identified by tabs ...... and No 4 spaces dont make a tab , only a tab makes a

makefile:4:***缺少分隔符。 停止

这是我的makefile: all:ll ll:ll.c gcc -c -Wall -Werror -02 c.c ll.c -o ll $@ $< clean : rm -fr ll 当我尝试make clean或make make ,我得到这个错误: :makefile:4: *** missing separator. Stop. 我该如何解决它? makefile与制表符有一个非常愚蠢的关系,每个规则的所有动作都由制表符标识......并且没有4个空格不制作制表符,只有制表符制作一个制表符...... 检查我使用命令cat -e -t -v ma

Seeing two accept events on epoll

I'm playing around with epoll on Linux for the first time and see some strange behavior. Specificall, when I connect with a client to a socket, I see two events emitted by epoll_wait on the server side. When I call accept on the second attempt I get a "temporary unavailable" error. Here's the simple client code: #include <stdio.h> #include <stdlib.h> #include &l

在epoll上看到两个接受事件

我第一次在Linux上玩epoll,看到一些奇怪的行为。 特别是,当我将客户端连接到套接字时,我会在服务器端看到epoll_wait发出的两个事件。 当我在第二次尝试时调用accept时,会出现“临时不可用”错误。 以下是简单的客户端代码: #include <stdio.h> #include <stdlib.h> #include <sys/socket.h> #include <sys/un.h> #include <unistd.h> const char* msg = "friendly ping"; int main(int a

epoll and send lag

I'm using Linux 64 bit Linux scv 3.2.0-39-generic #62-Ubuntu SMP Thu Feb 28 00:28:53 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux and have two processes using sockets which run on the same physical host. One process (A) sends on a TCP/IP socket (would be a local socket given the host is the same) the following pieces of data: 276 bytes 16 bytes This is done in 0.000023 seconds form process

epoll并发送滞后

我正在使用Linux 64位Linux scv 3.2.0-39-generic #62-Ubuntu SMP Thu Feb 28 00:28:53 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux并且有两个使用在同一物理主机上运行的套接字的进程。 一个进程(A)在TCP / IP套接字(在主机相同的情况下是本地套接字)上发送以下几条数据: 276字节 16个字节 这是在0.000023秒的表格过程A中完成的。正在发送的数据调用2次send套接字API。 另一个过程(B)使用epoll_wait(efd, events

multithreaded epoll

I am creating a multithreaded server using epoll (edge-triggered) and non-blocking sockets. Currently I'm creating an event loop on the main thread and waiting for notifications and it works correctly I have to choose between two approaches to make it multithreaded: Create an event loop for each thread and add the server socket's file descriptor to look for notifications on each thre

多线程epoll

我正在使用epoll(边缘触发)和非阻塞套接字创建多线程服务器。 目前我正在主线程上创建一个事件循环并等待通知,并且它可以正常工作 我必须在两种方法之间进行选择以使其成为多线程: 为每个线程创建一个事件循环,并添加服务器套接字的文件描述符以在每个线程上查找通知。 (可能吗?我的意思是:epoll是线程安全的吗?) 创建单个事件循环并等待通知。 每当收到通知时,产生一个线程来处理它。 如果我使用第一种方

epoll with Edge Triggered event

The man page of epoll : http://linux.die.net/man/7/epoll have a sample code for Edge Triggered like the follwoing : for (;;) { nfds = epoll_wait(epollfd, events, MAX_EVENTS, -1); if (nfds == -1) { perror("epoll_pwait"); exit(EXIT_FAILURE); } for (n = 0; n < nfds; ++n) { if (events[n].data.fd == listen_sock) { conn_sock = accept(listen_s

带边缘触发事件的epoll

epoll的手册页: http://linux.die.net/man/7/epoll 有一个边缘触发的示例代码,如下所示: for (;;) { nfds = epoll_wait(epollfd, events, MAX_EVENTS, -1); if (nfds == -1) { perror("epoll_pwait"); exit(EXIT_FAILURE); } for (n = 0; n < nfds; ++n) { if (events[n].data.fd == listen_sock) { conn_sock = accept(listen_sock, (

Data is not received correctly from TCP socket using C

I am using Ubuntu 12.04 32 bit edition I wrote a program to receive an XML file from a TCP client. The same program is receiving data from another process by a unix domain socket also. For that I am using the poll() system call. My problem is, some times I am not getting the XML data correctly or some time it was missing too. But since I am using TCP, if there is a data loss client will know

未使用C从TCP套接字正确接收数据

我正在使用Ubuntu 12.04 32位版本我编写了一个程序来从TCP客户端接收XML文件。 同一个程序也是通过unix域套接字从另一个进程接收数据。 为此,我正在使用poll()系统调用。 我的问题是,有些时候我没有正确地获取XML数据,或者有些时候它缺少了。 但是由于我使用的是TCP,如果有客户端会知道数据丢失。 但客户端不显示任何错误。 任何人都可以告诉我为什么会发生这种情况? 我可以提供一些代码: int config_server_t

Socket server with epoll and threads

I am trying to create a socket server in C for a Collaborative real-time editor http://en.wikipedia.org/wiki/Collaborative_real-time_editor but I don't know what is the best server architecture for it. At the first, I was trying to use select for the socket server but after that, I was reading about epoll and now I think that epoll is the best choice because the client will send every lette

带epoll和线程的套接字服务器

我正尝试在C中创建一个套接字服务器,用于协作实时编辑器http://en.wikipedia.org/wiki/Collaborative_real-time_editor,但我不知道什么是最好的服务器体系结构。 首先,我试图使用套接字服务器的select,但在此之后,我正在阅读epoll,现在我认为epoll是最好的选择,因为客户端会发送每个字母,用户将在textarea上写入服务器,所以服务器将有数据处理的分配。 另外,我想使用epoll的线程,但我不知道如何使用它们。 我想