使用Caliburn.Micro,我想知道将EF4实体暴露为ViewModel的属性(这里 和此处讨论的一种技术)的优缺点.这使我可以避免为每个字段编写getter和setter(参见下面的OneCustomer).缺点是我需要在XAML中编写所有绑定语句(LastName不在ViewModel中,但需要XAML绑定).如果我坚持使用每个字段的属性填充我的ViewModel的规定技术(如下面的FirstName),我最终必须编写大量的额外代码才能调用NotifyOfProperyChange.该应用程序将非常庞大.我应该将每个实体公开为ViewModel的属性吗?
在我的ViewModel中:
private MyEntities _context = new MyEntities();
private BindableCollection<Customer> _custBindableCollection;
private Customer _oneCustomer;
private string _firstName;
public void Load()
{
_custBindableCollection = new BindableCollection<Customer>(_context.Customers.Where(row => row.CustomerType == "FOO"));
AllCustomers = _custBindableCollection;
_oneCustomer = _custBindableCollection.FirstOrDefault();
FirstName = _oneCustomer.FirstName;
OneCustomer = _oneCustomer;
}
public BindableCollection<Customer> AllCustomers
{
get { return _custBindableCollection;}
set {_custBindableCollection = value;
NotifyOfPropertyChange(() => AllCustomers);}
}
public Customer OneCustomer
{
get { return _oneCustomer;}
set { _oneCustomer = value;
NotifyOfPropertyChange(() => OneCustomer);}
}
public …Run Code Online (Sandbox Code Playgroud) 我想在我的ASP.Net MVC 3应用程序中使用Twitter的Bootstrap.我下载了bootstrap.css并将其添加到Content文件夹中的项目中.我打开_Layout.cshtml并添加了一个指向该文件的链接:
<head>
<title>@ViewBag.Title</title>
<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/bootstrap.css")" rel="stylesheet" type="text/css" />
Run Code Online (Sandbox Code Playgroud)
当我运行应用程序时,不应用样式表.如何从_Layout.cshtml文件中引用Site.css和bootstrap.css?
安装Visual Studio 2012后,"发布"功能停止工作.发布无法找到必备的Microsoft .Net Framework 4 Client Profile(x86和x64).以前在Visual Studio 2010中,这很好用.我使用的是64位Windows 7.
确切的Visual Studio 2012错误消息如下:
Error 104 - To enable 'Download prerequisites from the same location
as my application' in the Prerequisites dialog box, you must download file
'DotNetFX40Client\dotNetFx40_Client_x86_x64.exe' for item 'Microsoft .NET
Framework 4 Client Profile (x86 and x64)' to your local machine. For more
information, see http://go.microsoft.com/fwlink/?LinkId=239883
Run Code Online (Sandbox Code Playgroud)
我把文件dotNetFx40_Client_setup.exe放在了以下位置:
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\Bootstrapper\Packages\DotNetFX40Client
我也将它留在原来的位置(注意v7.0A):
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages\DotNetFX40Client
编辑(解决问题后):我看到正确的安装文件(dotNetFx40_Client_x86_x64.exe)实际上在v7.0A文件夹中.如果我只是从那里复制它一切都会工作(而不是下载错误的设置).
当我更改"从我的应用程序的相同位置下载先决条件"选项到"从组件供应商的网站下载先决条件"(在项目属性 - >发布 - …
当DomainDataSource获取数据时,我的BusyIndicator按预期工作.但是当我在代码中将IsBusy设置为true时,控件保持不可见.
我正在使用Silverlight 4和工具包BusyIndicator.在XAML中,我将BusyIndicator.IsBusy属性绑定到我的DomainDataSource控件的IsBusy属性.BusyIndicator控件包装我的主Grid(LayoutRoot)和所有子控件.
<toolkit:BusyIndicator IsBusy="{Binding ElementName=labSampleDomainDataSource, Path=IsBusy}" Name="busyIndicator1">
<Grid x:Name="LayoutRoot">
</Grid>
</toolkit:BusyIndicator>
Run Code Online (Sandbox Code Playgroud)
问题是当我设置busyIndicator1 = true时BusyIndicator没有显示; 在按钮单击事件中.知道我做错了什么吗?
silverlight silverlight-toolkit silverlight-4.0 busyindicator
当作为来自Web服务的NVarChar参数插入Sql Server 2005时,我的回车丢失.我知道回车符存在于Web服务字段中,因为当我将相同的数据绑定到WPF ComboBox时,我看到返回发生在正确的位置.
代码看起来像这样:
string insertSQL = "INSERT INTO myTable (FieldWithCrLf,...) VALUES (@FieldWithCrLf,...)";
dbConn.Open();
using (SqlCommand cmd = new SqlCommand(@insertSQL, dbConn))
{
cmd.Parameters.Add("@FieldWithCrLf", SqlDbType.NVarChar, 4000);
...
}
foreach (WebServiceRecord rec in allDataFromWebService)
{
cmd.Parameters["@FieldWithCrLfr"].Value = rec.FieldWithCrLfFromWebService;
...
cmd.ExecuteNonQuery();
}
Run Code Online (Sandbox Code Playgroud)
如何保留回车符/换行符以便它们存储在我的Sql Server字段中?
我的C#程序允许用户按优先级对项目进行数字排名。我编写了一个例程,当用户修改项目等级时,该例程将自动按等级对项目进行排序。因此,当优先级为3的项目更改为1时,例程将诉诸前3个项目。那些先前排名为1、2的项目将成为排名2、3。类似地,当优先级为1的项目成为优先级3时,那些排名为2、3的项目将成为1、2。
现有的集合类是否内置了此功能?如果是这样,代码示例也将不胜感激。
wpf ×3
.net ×1
asp.net ×1
c# ×1
clickonce ×1
collections ×1
cracking ×1
css ×1
ms-access ×1
mvvm ×1
publishing ×1
radgrid ×1
silverlight ×1
sorting ×1
sql-server ×1
telerik ×1
web-services ×1
webforms ×1
xaml ×1