asp.net web api中缺少命名空间。请帮助我。 [英] namespace missing in asp.net web api. kindly help me out.

查看:56
本文介绍了asp.net web api中缺少命名空间。请帮助我。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用System;

使用System.Collections.Generic;

使用System.Linq;

使用System.Web;

使用System.Net;

使用System.Net.Http;

使用System.Web.Http;

使用winwebapi 。模型;



public ContactDetail Add(ContactDetail contact)

{



var addedContact = context.ContactDetails.Add(contact);

context.SaveChanges();

return addedContact;



}







我在这里创建asp.net web api crud操作。你能看到添加功能吗?它显示如下错误



system.data.objects.objesctset< winwebapi.contactdetail>'确实包含添加和扩展方法的定义'添加'接受第一个参数输入'system.data.objects< winwebapi.contactdetail>找不到(你是否错过了使用指令ro程序集引用?)我想我可能会错过名称空间。那么,请帮助我为什么我得到这个错误以及如何解决?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using winwebapi.Models;

public ContactDetail Add(ContactDetail contact)
{

var addedContact = context.ContactDetails.Add(contact);
context.SaveChanges();
return addedContact;

}



hi here i am creating asp.net web api crud operations. can you see add function? it shows an error like follows

system.data.objects.objesctset<winwebapi.contactdetail>'does contain definition for Add and extension method 'Add' accepting a first argument type 'system.data.objects<winwebapi.contactdetail> could not be found (are you missing a using directive ro assembly reference?) i think i may miss namespace. so, pls help me why i got this error and how to solve?

推荐答案

尝试使用如下所述的AddObject:



Try to use AddObject as mentioned below :

context.ContactDetails.AddObject(contact);


这篇关于asp.net web api中缺少命名空间。请帮助我。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆