嘗試轉換爲EF 5,但遇到CreateQuery
問題。任何幫助將非常感激。先謝謝你。使用實體框架的CreateQuery 5
這是代碼:
using System;
using System.ServiceModel;
using System.Data.Objects;
namespace TestingOneServiceRole
{
public class Service1 : IService1
{
public void AddUser(string fullName, string userName, string password)
{
using (var context = new MyEntities())
{
context.AddToUser(new User()
{
UserName = userName,
Password = password,
FullName = fullName,
});
context.SaveChanges();
}
}
public string UserLoginNow(string username, string password)
{
string query = @"SELECT value blah.FullName FROM MyEntities.blah AS User WHERE blah.UserName = @username AND blah.Password = @password";
ObjectParameter[] parameters = new ObjectParameter[2];
parameters[0] = new ObjectParameter("username", username);
parameters[1] = new ObjectParameter("password", password);
using (var context = MyEntities())
{
ObjectQuery<string> results = context.CreateQuery<string>(query, parameters);
foreach (string result in results)
{
etc.......
? – GrandMasterFlush 2013-04-26 15:56:50
我收到「TestingOneServiceRole.MyEntities」不包含「CreateQuery」的定義並且沒有擴展方法的錯誤... – Robin 2013-04-26 16:05:05