不久,我想在我的表上创建复合键,保留主键,以提高sql server搜索性能.每当我搜索没有主键的实体(即一串GUID)时,性能问题就会发生在200k数据表上.假设我有3个班级
public class Device{
public int ID { get; set; }
public string UDID { get; set; }
public string ApplicationKey { get; set; }
public string PlatformKey { get; set; }
public ICollection<NotificationMessageDevice> DeviceMessages { get; set; }
}
public class NotificationMessageDevice {
[Column(Order = 0), Key, ForeignKey("NotificationMessage")]
public int NotificationMessage_ID { get; set; }
[Column(Order = 1), Key, ForeignKey("Device")]
public int Device_ID { get; set; }
public virtual Device Device { get; set; }
public virtual NotificationMessage …Run Code Online (Sandbox Code Playgroud) CodeLens因为某些原因在我现在处理的项目解决方案中停止了工作.它没有显示引用而是" - references".但是,当我用另一个项目打开Visual Studio它就像charm一样.我可以确认CodeLens已启用.你有什么想法让它发挥作用吗?
我为我的客户创建了一个应用程序.我们已经通过我的帐户发布了该申请.现在,他们想要将开发者名称更改为公司名称.有没有办法改变开发者名称?我可以将我的应用程序移动到他们的企业帐户,以便开发人员名称更改为他们的公司名
我在web api中有一个新方法
[HttpPost]
public ApiResponse PushMessage( [FromUri] string x, [FromUri] string y, [FromBody] Request Request)
Run Code Online (Sandbox Code Playgroud)
请求类就像
public class Request
{
public string Message { get; set; }
public bool TestingMode { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我正在使用PostBody对localhost/Pusher/PushMessage进行查询?x = foo&y = bar:
{ Message: "foobar" , TestingMode:true }
Run Code Online (Sandbox Code Playgroud)
我错过了什么吗?
我正在序列化对象并从我的Web服务返回json.但是,我试图从序列化的json中省略null属性.有没有办法做到这一点?我正在使用Web Api MVC 4 beta.
我需要对包含Dictionary作为参数的方法发出GET请求.我浏览但无法找到有关如何发送字典的任何信息,所以我的请求命中我的方法.方法签名如下所示
public void AddItems(Dictionary<string,object> Items)
Run Code Online (Sandbox Code Playgroud)
最好的祝福,
凯末尔
我为我的web api创建了一个ActionFilterAttribute以授权人员.通过RequestUri获取accessToken是可以的,但是我想在表单数据中发送它.在ActionFilterAttribute的onActionExecuting方法中读取Request.Content时,服务器始终具有空结果.我怎么解决这个问题?代码如下所示:
public class RequireAuthorization : ActionFilterAttribute
{
public override void OnActionExecuting(System.Web.Http.Controllers.HttpActionContext actionContext)
{
actionContext.Request.Content.ReadAsStringAsync().ContinueWith((t) =>
{
try
{
//query will result in empty string
string query = t.Result;
string UserID = HttpUtility.ParseQueryString(query).Get("UserID");
string accessToken = HttpUtility.ParseQueryString(query).Get("AccessToken");
UserRepository repository = new UserRepository();
repository.IsTokenValid(Convert.ToInt32(UserID), accessToken);
}
catch (Exception ex)
{
var response = new HttpResponseMessage
{
Content =
new StringContent("This token is not valid, please refresh token or obtain valid token!"),
StatusCode = HttpStatusCode.Unauthorized
};
throw new HttpResponseException(response);
}
});
base.OnActionExecuting(actionContext); …Run Code Online (Sandbox Code Playgroud) 我正在尝试为我的网络API服务发帖.重点是发送消息时
{ message: "it is done" }
Run Code Online (Sandbox Code Playgroud)
工作正常.但是当我在我的消息中使用像çıöpş这样的特殊字符时,它无法转换我的json以使post对象保持为null.我能做什么?这既是当前的文化问题,也可能是其他问题.我试图将我的post参数发送为带有编码HttpUtility类的HtmlEncoded样式,但它也不起作用.
public class Animal{
public string Message {get;set;}
}
Run Code Online (Sandbox Code Playgroud)
Web API方法
public void DoSomething(Animal a){
}
Run Code Online (Sandbox Code Playgroud)
客户
Animal a = new Animal();
a.Message = "öç?istltl";
string postDataString = JsonConvert.SerializeObject(a);
string URL = "http://localhost/Values/DoSomething";
WebClient client = new WebClient();
client.UploadStringCompleted += client_UploadStringCompleted;
client.Headers["Content-Type"] = "application/json;charset=utf-8";
client.UploadStringAsync(new Uri(URL), "POST",postDataString);
Run Code Online (Sandbox Code Playgroud)
最好的祝福,
凯末尔
我有一个类似下面的类发布到asp.net web api
public class PostData
{
public int ID { get; set; }
public int[] SelectedChoiceIDs { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
在我的ApiController中有一个名为send的方法,它将PostData对象作为参数.
public bool Send(PostData data)
{
}
Run Code Online (Sandbox Code Playgroud)
问题是每当我跟踪方法Web API没有绑定到整数数组时,即SelectedChoiceIDs属性.我如何强制将整数数组绑定到" SelectedChoiceIDs"属性?
我发送的数据就像
{ "ID" : 3 , "SelectedChoiceIDs" : [ 3,4,5,6 ] }
Run Code Online (Sandbox Code Playgroud)