我有一个课程项目和类别
Class Item
{
private long ItemId;
private String ItemName;
private String ItemDescription;
private String ItemWebSite;
private String Condition;
private long Price;
private String Brand;
private String AttributeDescription;
private Category ProductCategory;
private Set <Picture> Pictures= new HashSet <Picture>();
//getters and setters
}
Class Category
{
private long CategoryId;
private String CategoryName;
private Category ParentCategory;
private Set <Category> SubCategory=new HashSet <Category> ();
private Set <Attribute> AllAttributes= new HashSet <Attribute>();
//getters and setters
}
Run Code Online (Sandbox Code Playgroud)
但是当我做下面的查询时:
long id=841;
Criteria crit =session.createCriteria(Item.class).add(Restrictions.eq("ProductCategory",id));
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
Caused …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用键:String,value:定义Map文本(Any)=>String.我尝试了以下,但得到语法错误:
def foo(x: Int): String = /...
def bar(x: Boolean): String = /...
val m = Map[String, (Any) => String]("hello" -> foo, "goodbye" -> bar)
Run Code Online (Sandbox Code Playgroud) VS2010,Silverlight 4.0.
有没有人知道是否有办法让Visual Studio在编译用于调试的Silverlight项目时将javascript(或其他任何内容)添加到它生成的html测试页面中?它是否使用模板,如果是,它在哪里?
新手到实体框架这里.使用VS 2010和SQL Server 2008 express DB.
添加新表后,我无法刷新实体数据模型.所以,我按照我在这里找到的建议删除并重新生成模型.
我进入实体数据模型向导的"选择您的数据连接"部分,并选中"将Web.config中的实体连接设置保存为:".但是,我现有的名字附加了1.例如,MyDatabaseEntities现在是MyDatabaseEntities1.当然,我不希望附加"1".我在Web.config中删除了现有的连接字符串,并在我的解决方案中删除了对该名称的所有引用.然而,当我尝试继续时,我遇到以下错误:
"'MyDatabaseEntites'与应用程序设置中的现有属性名称冲突.请选择其他名称"
我无法在解决方案的任何位置找到对该名称的引用.我可以取消选中该选项,它将继续,但它仍然不会在数据库中添加两个表.接下来,我完全关闭所有内容,重新启动,然后再次尝试.这次我没有得到上面的错误,但是我的三个新表中的两个仍然没有被添加到edmx模型中.
任何想法都表示赞赏.此外,即使在VS2010/.NET中,这似乎仍然非常错误.帮助恢复我的信念...我觉得此时放弃实体框架.基于到目前为止我的经验和一些张贴在这里的其他问题,我觉得我会花更多的时间追逐实体框架的陌生感比写有用的代码.
更新:我找到了一个决议.设计师不会显示错误.您必须查看本机XML(edmx文件)才能查看错误.请参见此处: ADO.NET实体框架:更新向导不会添加表
我不知道这里发生了什么......我只是想检查模型字段的值,然后相应地更新它......任何帮助或见解都值得赞赏!
模型:
class UserProfile(models.Model):
user = models.ForeignKey(User, unique=True)
beta = models.CharField(max_length=1, blank=True, null=True)
Run Code Online (Sandbox Code Playgroud)
视图:
from internal.accounts.models import UserProfile
from django.contrib.auth.models import User
@login_required
def beta_testers(request):
user = User.objects.get(username=request.user.username)
user_profile = user.get_profile()
count = UserProfile.objects.filter(beta='1').count()
if count < 50 and not user_profile['beta']:
user_profile['beta'] = '1'
user_profile.save()
Run Code Online (Sandbox Code Playgroud)
错误:
TypeError at /utilities/beta-signup/
'UserProfile' object is unsubscriptable
Request Method: GET
Request URL: http://localhost/utilities/beta-signup/?x=1&y=15
Django Version: 1.2.1
Exception Type: TypeError
Exception Value:
'UserProfile' object is unsubscriptable
Exception Location: C:/django\internal\cms_helper\views.py in beta_testers, line 284
Run Code Online (Sandbox Code Playgroud) 我有一些C++库.有没有办法以跨平台的方式在Silverlight中使用它们(在Linux/Mac/PC上)?如果可能,我不想使用C++/CLI.
我用谷歌搜索了这篇文章,说COM是唯一的方法.但是,我被告知Silverlight4支持PInvoke.
我正在使用wpf工具包AutoCompleteBox,我已经设置了Item模板.问题:弹出列表中的项目看起来很棒,但它对上面的文本框(选定项目)没有生效.

XAML:
<Controls:AutoCompleteBox x:Name="x" ItemFilter="SearchPerson" Margin="20">
<Controls:AutoCompleteBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}" />
<Rectangle Width="10" Height="10" Fill="LightGreen"/>
<TextBlock Text="{Binding Age}" />
</StackPanel>
</DataTemplate>
</Controls:AutoCompleteBox.ItemTemplate>
</Controls:AutoCompleteBox>
Run Code Online (Sandbox Code Playgroud)
代码背后:
public partial class MainWindow : Window
{
public List<Person> Persons { get; set; }
public MainWindow() {
InitializeComponent();
Persons = new List<Person> {
new Person{Name = "Jhon",Age=35},
new Person{Name = "Kelly",Age=40}};
x.ItemsSource = Persons;
DataContext = this;
}
bool SearchPerson(string search, object value) {
return (value as Person).Name.ToLower().Contains(search);
}
}
public class Person …Run Code Online (Sandbox Code Playgroud) 我有一个带有标题的wordpress网站,如果标题有超过50个字符,我需要在标题的末尾添加省略号(...)并将标题停止在50个字符.下面是我正在编写的PHP,但它似乎无法正常工作,寻求PHP大师教我正确的方法.任何帮助将不胜感激.
<?php if (strlen("the_title()") > 50) { ?>
<?php the_title(); ?>
<?php } if (strlen("the_title()") < 50) { ?>
<?php echo substr(get_the_title(), 0, 50); ?>...
<?php } ?>
Run Code Online (Sandbox Code Playgroud) 我从文件中得到的文字有以下字符串:1"-DC-19082-A3
获得该行后,我得到以下字符串(在调试时得到它):"\"1 \"\" - DC-19082-A3 \""
因为我正在搜索数据库,所以没有任何用途
任何想法我怎么能回到原来的?
我已经看到StreamWriter.WriteLine可以完成这项工作,但我不想为此创建任何文件.
我尝试了以下,但它没有用
StringBuilder sb = new StringBuilder();
sb.Append(@"\");
sb.Append('"');
string strToReplace = sb.ToString();
string lineNumberToSearchFor = lineNumber.Replace(strToReplace, string.Empty);
Run Code Online (Sandbox Code Playgroud)
希望有一个简单的方法来实现这一目标
非常感谢!