Tag: C#的

entity frameworkcaching问题

我是entity framework的新手。 我已经在我的数据库中使用EF得到了一些值。 它完美地返回,值显示在标签中。 但是,当我删除我的表中的所有值(不使用EF),EF查询返回我的旧值。 我知道EF将这些值存储在caching中,并返回caching的数据以供后续运行。 它是否正确? 那么我怎样才能解决问题,当我已经删除了我的数据库中的所有值,但EF返回旧值? 编辑 : 现在我使用datamodel.SaveChanges() 。 但现在它返回相同的旧值。 我的示例查询如下所示: SchoolBriefcaseEntities datamodel = new SchoolBriefcaseEntities(); datamodel.SaveChanges(); List<Compliance> compliance=new List<Compliance>(); IList<ComplianceModel> complianceModel; if (HttpContext.Current.User.IsInRole("SuperAdmin")) { compliance = datamodel.Compliances.Where(c => c.School.DistrictId == districtId).ToList(); }

如何select哪里不存在使用LINQ?

我必须列出要分配给“ 员工 ”的所有“ class次 ”数据,但是如果class次数据已经存在于员工数据中,则不得包含class次数据。 让我们看看图片样本。 这个查询解决了这个问题。 我在这里find了这个: 斯科特的博客 select * from shift where not exists (select 1 from employeeshift where shift.shiftid = employeeshift.shiftid and employeeshift.empid = 57); 我们来看看结果: 现在我的问题是,我怎么能在linQ中做到这一点? 我正在使用entity framework。 希望有人可以帮忙。 非常感谢!!!

在WPFbutton中添加图像

我试过这个解决scheme: <Button> <StackPanel> <Image Source="Pictures/img.jpg" /> <TextBlock>Blablabla</TextBlock> </StackPanel> </Button> 但是我只能在项目窗口看到图像,当我启动程序时,它就消失了。 如果我尝试这个: Image img = new Image(); img.Source = new BitmapImage(new Uri("foo.png")); StackPanel stackPnl = new StackPanel(); stackPnl.Orientation = Orientation.Horizontal; stackPnl.Margin = new Thickness(10); stackPnl.Children.Add(img); Button btn = new Button(); btn.Content = stackPnl; 我得到了“PresentationFramework.dll”中的“System.Windows.Markup.XamlParseException”exception。 你能帮我find解决办法吗? 谢谢。

以编程方式创buildPowerPoint演示文稿

有没有办法以编程方式创buildPowerPoint演示文稿? 如果可能,我想使用C#并创buildPowerPoint 2003演示文稿。

C#中的Heredocstring

在C#中有string的heredoc符号,最好是我不必逃避任何东西 (包括双引号,这是在逐字string中的怪癖)?

一个class轮从列表<T>转换为vector<T>

有一个单一的class轮将list<T>转换为vector<T> ? 谷歌search返回给我很多结果,使用手动,冗长的转换,这使我呕吐。 我们是否应该去做那么简单的事情,像列表 – 向量转换一样简单?

在C ++中使用“this”关键字

可能重复: 在C ++中过度使用这个代码的气味 什么时候应该在C ++中使用“this”关键字? 有什么理由使用这个 – > 在C ++中,关键字“this”通常被忽略? 例如: Person::Person(int age) { _age = age; } 而不是: Person::Person(int age) { this->_age = age; }

Resharper Ctrl-T映射丢失

我似乎已经失去了快速查找类的Resharper Ctrl + T映射,我尝试了这里描述的解决scheme: 在安装了Resharper的Visual Studio中,键盘快捷键未处于活动状态 具体的答案是: 我首先尝试重置所有Visual Studio设置(工具>导入和导出设置>重置所有设置),然后转到Resharper> Options> Keyboard&Menus并重新应用键盘快捷方式。 和这个: 设置为Resharper /选项/键盘和菜单/无/应用和保存 接着 Resharper /选项/键盘和菜单/设置为Visual Studio /应用并保存 后者没有做任何事情(没有显着的积极结果),前者的结果如下: (Ctrl + T)被按下。 等待和弦的第二把钥匙。 所以它看起来像VS试图处理命令,而不是Resharper。 Alt + Enter按预期工作,所以并不是Resharper完全分离。 有想法该怎么解决这个吗?

C硬编码数组作为memcpy参数

我想传入一个硬编码的字符数组作为memcpy的source参数…这样的事情: memcpy(dest, {0xE3,0x83,0xA2,0xA4,0xCB} ,5); 这与clang编译给出了以下错误: cccc.c:28:14: error: expected expression 如果我修改它(见额外的括号): memcpy(dest,({0xAB,0x13,0xF9,0x93,0xB5}),5); clang给出的错误是: cccc.c:26:14: warning: incompatible integer to pointer conversion passing 'int' to parameter of type 'const void *' [-Wint-conversion] cccc.c:28:40: error: expected ';' after expression memcpy(c+110,({0xAB,0x13,0xF9,0x93,0xB5}),5); 所以,这个问题: 如何传入硬编码数组作为memcpy的源参数( http://www.cplusplus.com/reference/cstring/memcpy/ ) 我努力了: (void*)(&{0xAB,0x13,0xF9,0x93,0xB5}[0]) – syntax error {0xAB,0x13,0xF9,0x93,0xB5} – syntax error ({0xAB,0x13,0xF9,0x93,0xB5}) – see above (char[])({0xE3,0x83,0xA2,0xA4,0xCB}) – […]

asp.net mvc:如何将非wwwredirect到www,反之亦然

我想将所有wwwstream量redirect到非wwwstream量 我已经复制到我的web.config <system.webServer> / <rewrite> / <rules> <rule name="Remove WWW prefix" > <match url="(.*)" ignoreCase="true" /> <conditions> <add input="{HTTP_HOST}" pattern="^www\.domain\.com" /> </conditions> <action type="Redirect" url="http://domain.com/{R:1}" redirectType="Permanent" /> </rule> 每个这个职位 如何将“www”URLredirect到没有“www”URL或反之亦然? 但我有500内部服务器错误。