我知道很多:Linq2Sql不支持很多,但我正在解决一个问题
我正在使用我的小SO克隆,我有一个带有问题的表和一个带有标签和连接表QuestionTag的表,所以我有一个经典的很多:问题和标签之间的许多关系.
要在首页上显示问题列表,我有这个类,我想从Linq2Sql查询中填写
public class ListQuestion
{
public int QuestionID { get; set; }
public string Title{ get; set; }
public IEnumerable<Tag> Tags { get; set; }
}
public IEnumerable<ListQuestion> GetQuestions()
{
from q in Questions
.................
select new ListQuestion{ ... }
}
Run Code Online (Sandbox Code Playgroud)
问题是我应该如何填写Tag集合.我发现在单个查询中不可能这样做,所以我将其分为2个查询,1个用于获取问题,1个用于获取标记,然后尝试加入它们.我知道很多:实体框架支持很多,所以他们是如何做到的?你会怎么做?任何替代方法?查询当然应该是有效的.
我应该使用哪个?
<input type="hidden" name="first_name"
value="<%= person.first_name %>" />
Run Code Online (Sandbox Code Playgroud)
要么
<input type="hidden" name="first_name"
value="<%= Html.Encode( person.first_name ) %>" />
Run Code Online (Sandbox Code Playgroud) 我试图使用StreamReader打开一个文件,我想设置一个编码,但我希望它采取默认的Windows编码...我怎么能改变我的窗口编码???
我创建了一个转换器,从double转换为整数.
但是行"return(int)value;" 总是得到"指定的演员表无效".
我该怎么做才能让我的Converter成功转换一个double并发回一个整数?
转换器:
namespace TestChangeAngle
{
[ValueConversion(typeof(double), typeof(int))]
class DoubleToIntegerConverter : IValueConverter
{
#region IValueConverter Members
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return (int)value;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
#endregion
}
}
Run Code Online (Sandbox Code Playgroud)
XAML:
<Page x:Class="TestChangeAngle.Page1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:TestChangeAngle"
Title="Page1">
<Page.Resources>
<local:DoubleToIntegerConverter x:Key="DoubleToIntegerConverter"/>
</Page.Resources>
<StackPanel HorizontalAlignment="Left" Margin="20">
<Image Source="images\logo2.png"
RenderTransformOrigin="0.5, 0.5"
Width="100"
Margin="10">
<Image.RenderTransform>
<RotateTransform Angle="{Binding ElementName=TheSlider, Path=Value}"/>
</Image.RenderTransform>
</Image>
<Slider x:Name="TheSlider"
Width="200" …Run Code Online (Sandbox Code Playgroud) 我创建了一个工作流程,我通过WorkflowInstance.Run()运行它.这个工作流程有很多书签,我希望能够查询哪个书签负责当前的空闲状态.
我怎么能这样做?
谢谢
我似乎无法在Silverlight中找到Label控件.如果我把XAML放在任何地方,我会收到编译错误.
我们的应用程序在画布上有许多对象; 画布包含在滚动查看器中.我们还有一个滑块控件和一些按钮,总是位于窗口顶部的中心.
我试图通过捕获应用程序的位图来打印应用程序,但没有任何"装饰" - 滑块,按钮或滚动条.
_scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;
_scrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden;
var s = xSlider;
s.Visibility = Visibility.Collapsed;
var b = xPlusButton;
b.Visibility = Visibility.Collapsed;
b = xMinusButton;
b.Visibility = Visibility.Collapsed;
b = xButton;
b.Visibility = Visibility.Collapsed;
Run Code Online (Sandbox Code Playgroud)
正如预期的那样,滑块和按钮是隐藏的,但滚动条不是.
我怀疑应用程序需要重新绘制布局才能隐藏滚动条.有没有办法让这种情况发生?由于SL 4中的打印操作必须由UI手势启动,因此这变得更加复杂.没有办法(AFAIK)以编程方式启动,因此这个重绘必须在其中一个PrintDocument事件处理程序中进行.
谢谢你的任何建议......
我创建了一个用户控件,我将其用于不同的目的.我已经定义了一个包含UIElement的依赖属性,我将其作为用户控件中某个区域的内容呈现.
当我使用这个控件时,我注意到了.并为content属性中的元素指定名称,它们在运行时始终显示为null.
MyContainer.xaml:
<UserControl x:Class="BSSApp.UI.Tests.MyContainer" x:Name="userControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<Border x:Name="LayoutRoot" Background="Green" CornerRadius="20" BorderBrush="#005500" BorderThickness="10">
<ContentPresenter Content="{Binding ElementName=userControl, Path=MyContent}" Margin="20"/>
</Border>
</UserControl>
Run Code Online (Sandbox Code Playgroud)
MyContainer.xaml.cs
namespace BSSApp.UI.Tests
{
public partial class MyContainer : UserControl
{
public static readonly DependencyProperty MyContentProperty =
DependencyProperty.Register("MyContent",
typeof(UIElement),
typeof(MyContainer),
new PropertyMetadata(new Grid()));
public UIElement MyContent
{
get
{
return (UIElement)GetValue(MyContentProperty);
}
set
{
SetValue(MyContentProperty, value);
}
}
public MyContainer()
{
InitializeComponent();
}
}
}
Run Code Online (Sandbox Code Playgroud)
而使用类:UserControlContentBug.xaml:
<UserControl x:Class="BSSApp.UI.Tests.UserControlContentBug"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:t="clr-namespace:BSSApp.UI.Tests"
mc:Ignorable="d" …Run Code Online (Sandbox Code Playgroud) 这是我的代码..
public DispatcherTimer tmr = new DispatcherTimer();
void somefunction (parameters){
if (something)
tmr.Start();
if (something else)
tmr.Stop();
}
Run Code Online (Sandbox Code Playgroud)
我的问题是我无法从第二个函数访问tmr对象的Start/Stop方法,因为它在不同的线程上运行!
有人能帮帮我吗??我被这个问题打了将近3天!:(
c# silverlight silverlight-4.0 windows-phone-7 windows-phone-7.1
我编写了一个代码来读取经典asp中的xml数据,如下所示:
<%
Dim objxml
Set objxml = Server.CreateObject("Microsoft.XMLDOM")
objxml.async = False
objxml.load ("/abc.in/xml.xml")
set ElemProperty = objxml.getElementsByTagName("Product")
set ElemEN = objxml.getElementsByTagName("Product/ProductCode")
set Elemtown = objxml.getElementsByTagName("Product/ProductName")
set Elemprovince = objxml.getElementsByTagName("Product/ProductPrice")
Response.Write(ElemProperty)
Response.Write(ElemEN)
Response.Write(Elemprovince)
For i=0 To (ElemProperty.length -1)
Response.Write " ProductCode = "
Response.Write(ElemEN)
Response.Write " ProductName = "
Response.Write(Elemtown) & "<br>"
Response.Write " ProductPrice = "
Response.Write(Elemprovince) & "<br>"
next
Set objxml = Nothing
%>
Run Code Online (Sandbox Code Playgroud)
此代码未提供正确的输出.请帮帮我.
xml是:
<Product>
<ProductCode>abc</ProductCode>
<ProductName>CC Skye Hinge Bracelet Cuff with Buckle in Black</ProductName>
</Product>
Run Code Online (Sandbox Code Playgroud) c# ×5
silverlight ×4
asp-classic ×1
asp.net-mvc ×1
casting ×1
converters ×1
file-io ×1
linq-to-sql ×1
many-to-many ×1
vb.net ×1
windows-xp ×1
workflow ×1
wpf ×1
xaml ×1
xml ×1
xss ×1