我通过阅读本文和许多其他文章编写了我自己的上下文,但没有一个主题解释了这个context.Entry(obj)
定义的位置,我的意思是即使阅读本文,我也无法理解如何实现此方法,并且我得到以下错误:
错误36'Domain.Entities.OurWebSiteContext'不包含'Entry'的定义,并且没有扩展方法'Entry'可以找到接受类型为'Domain.Entities.OurWebSiteContext'的第一个参数(你是否缺少using指令或者装配参考?)
请有人帮帮我
编辑>>
public class OurWebSiteContext : DbContext
{
public OurWebSiteContext(string connString)
: base(connString)
{
}
public DbSet<Article> Articles { get; set; }
public DbSet<Category> Categories { get; set; }
public DbSet<Comment> Comments { get; set; }
}
Run Code Online (Sandbox Code Playgroud) 我正在开发一个asp.net mvc 3.0应用程序,它具有简单的身份验证过程.用户填写一个通过ajax调用发送到服务器并获得响应的表单,但问题是使用以下方法:
FormsAuthentication.SetAuthCookie(person.LoginName,false);
Run Code Online (Sandbox Code Playgroud)
是不足以填充'HttpContext.Current.User',它需要运行以下方法:
FormsAuthentication.RedirectFromLoginPage("...");
Run Code Online (Sandbox Code Playgroud)
这里的问题是,正如我所提到的,loggin表单使用ajax表单,并使用json获取响应,因此无法重定向.
我怎么能填写'HttpContext.Current.User'?
谢谢.
更新:
这是注册方法:
[HttpPost]
public ActionResult Register(Person person)
{
var q = da.Persons.Where(x => x.LoginName == person.LoginName.ToLower()).FirstOrDefault();
if (q != null)
{
ModelState.AddModelError("", "Username is repettive, try other one");
return Json(new object[] { false, this.RenderPartialViewToString("RegisterControl", person) });
}
else
{
if (person.LoginName.ToLower() == "admin")
{
person.IsAdmin = true;
person.IsActive = true;
}
da.Persons.Add(person);
da.SaveChanges();
FormsAuthentication.SetAuthCookie(person.LoginName,false);
return Json(new object[] { true, "You have registered successfully!" });
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个datagridview,我填写如下:
var q= repository.GetStudents();//
dataGridView1.DataSource = null;
dataGridView1.Columns.Clear();
dataGridView1.DataSource = q;
dataGridView1.Columns.RemoveAt(1);
//Remove IsActive
//Cause I want to have my own implementation
dataGridView1.Columns[0].DataPropertyName = "StudentID";
dataGridView1.Columns[0].HeaderText = "Studunet ID";
dataGridView1.Columns[1].DataPropertyName = "IsActive";
dataGridView1.Columns[1].HeaderText = "Status";
Run Code Online (Sandbox Code Playgroud)
"IsActive"属性是布尔类型.当显示"IsActive"单元格时,它显示true/false.我想用我自己的自定义值替换它.
我正在根据这个例子开发一个应用程序.我在layout-land文件夹中为header.xml定义了横向布局,但是当我将方向更改为横向时,定义的布局不会出现在屏幕中.
知道为什么吗?
谢谢
更新 :
活动代码:
public class ACENewsFeedActivity extends ListActivity {
// Progress Dialog
private ProgressDialog pDialog;
// Array list for list view
ArrayList<HashMap<String, String>> rssItemList = new ArrayList<HashMap<String,String>>();
RSSParser rssParser = new RSSParser();
List<RSSItem> rssItems = new ArrayList<RSSItem>();
RssFeed rssFeed;
private static String TAG_TITLE = "title";
private static String TAG_LINK = "link";
private static String TAG_DESRIPTION = "description";
private static String TAG_PUB_DATE = "pubDate";
//private static String TAG_GUID = "guid"; // not used
/** Called when …
Run Code Online (Sandbox Code Playgroud) 我正在Windows 8 Visual Studio 11中开发一个应用程序,我想为DispatcherTimer实例定义一个事件处理程序,如下所示:
public sealed partial class BlankPage : Page
{
int timecounter = 10;
DispatcherTimer timer = new DispatcherTimer();
public BlankPage()
{
this.InitializeComponent();
timer.Tick += new EventHandler(HandleTick);
}
private void HandleTick(object s,EventArgs e)
{
timecounter--;
if (timecounter ==0)
{
//disable all buttons here
}
}
.....
}
Run Code Online (Sandbox Code Playgroud)
但是我得到以下错误:
Cannot implicitly convert type 'System.EventHandler' to 'System.EventHandler<object>'
Run Code Online (Sandbox Code Playgroud)
我是widows 8应用程序的新手开发者.
你能帮帮我吗?
我将在我的Android应用程序中使用地图,我应该使用谷歌播放服务.我阅读了大量的Q \这里一个像这样.在上面提到的问题中,接受的答案建议使用旧版本的google play服务lib,就像Froyo那样.我下载了谷歌播放服务r10并在我的应用程序中使用它,但我收到了错误.
如果我从清单中排除这行代码:
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
Run Code Online (Sandbox Code Playgroud)
并在我的设备中运行应用程序(我的设备中当前版本的google playe服务是3.2.66),它会抛出错误:
java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4030500 but found 0. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
Run Code Online (Sandbox Code Playgroud)
如果我用android:value = 4030500包含它,该应用程序运行,但说我应该更新我的"谷歌播放服务".
那么我应该把android:value或者我的方法完全正确呢?
问候
嗨我想在我的asp.net mvc appliation中使用Autofac,这是我在global.asxc文件中的代码:
protected void Application_Start()
{
....
var builder = new ContainerBuilder();
builder.RegisterControllers(Assembly.GetExecutingAssembly());
IContainer container = builder.Build();
DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
}
Run Code Online (Sandbox Code Playgroud)
但是当我运行项目时,我看到了这个错误:
该模块要求HttpApplication(全局应用程序类)实现IContainerProviderAccessor
怎么了 ?
我想用一个好的"国家空间"解决"河内塔"的问题.使用适当的状态空间是一些AI技术所建议的方式.拥有一个良好的状态空间,我希望能够构建一个搜索树,然后使用一些策略,如"DFS"(深度优先搜索)来找到解决方案.
我的问题是,我只是不知道如何开发一个好的状态空间然后用它来构建一个搜索树.任何人都可以描述如何为河内塔问题创建一个州空间吗?然后告诉我如何为此构建搜索树?
在阅读有关使用owin和webapi的autofac的问题和文章后,我遇到了注入服务的解决方案,但它不起作用.这是我的代码:
public class StartUp
{
public void Configuration(IAppBuilder app)
{
HttpConfiguration config = new HttpConfiguration();
WebApiConfig.Register(config);
var builder = new ContainerBuilder(); // Create the container builder.
builder.RegisterApiControllers(Assembly.GetExecutingAssembly()); // Register the Web API controllers.
var authcontext = new AuthContext();
builder.RegisterInstance(authcontext).AsSelf().SingleInstance();
//Updated
//var simpleauth = new SimpleAuthorizationServerProvider();
//Updated
// builder.RegisterInstance(simpleauth).SingleInstance().AsSelf().PropertiesAutowired();
builder.Register(x => new UserStore<IdentityUser>(authcontext)).As<IUserStore<IdentityUser>>();
//updated
builder.Register(x =>
{
var p = new SimpleAuthorizationServerProvider();
var userStore = x.Resolve<IUserStore<IdentityUser>>();
p.userManager = new UserManager<IdentityUser>(userStore);
return p;
}).AsSelf().PropertiesAutowired();
builder.RegisterType<AuthRepository>().As<IAuthRepository>().InstancePerRequest().PropertiesAutowired();
var container = builder.Build();
var resolver = …
Run Code Online (Sandbox Code Playgroud) android ×2
autofac ×2
ajax ×1
asp.net-mvc ×1
c# ×1
datagridview ×1
google-maps ×1
google-play ×1
mef ×1
owin ×1
windows-8 ×1
winforms ×1