I have an ADO.Net Data Service that I am using to do a data import. There are a number of entities that are linked to by most entities. To do that during import I create those entities first, save them and then use .SetLink(EntityImport, "NavigationProperty", CreatedEntity). Now the first issue that I ran into was that the context did not always know about CreatedEntity (this is due to each of the entities being imported independently and a creation of a …
我需要通过Web服务返回一个Dictionary(或一些List,我只是不知道),特别是通过WCF数据服务.看起来WCF数据服务不支持字典类型.
通过Web服务看起来像这样:
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
- <Employees xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices">
<element>employee1, True</element>
<element>employee2, False</element>
<element>employee3, True</element>
</Employees>
Run Code Online (Sandbox Code Playgroud)
我首先尝试了一个1维数组,这似乎工作,但当然只带来3个elemet数字的1维数组:
[WebGet]
public string[] Employees()
{
return new[]
{
"employee1",
"employee2",
"employee3"
};
}
Run Code Online (Sandbox Code Playgroud)
基本上,我需要一些List(?),每个都有两个参数,即EmployeeName和一个booleann值,IsActive.
任何建议将不胜感激.
更新:我在Web服务中添加了以下内容:
public class Employee
{
public string Name{ get; set; }
public bool IsActive{ get; set; }
public Employee(string name, bool isActive)
{
Name = name;
IsActive = isActive;
}
}
[WebGet]
public List<Employee> Employees()
{
var emp1 = new Employee("Test1", true);
var emp2 = new Employee("Test2", …Run Code Online (Sandbox Code Playgroud) 我有一个网址过滤器,如:t1?$ filter = ID eq 1&$ expand = t2/t3/t4/t5/t6.
现在,当我使用上下文运行此查询作为第一个查询时,我得到了所有内容!当我从另一个页面运行同一个,并且它是使用相同的objectcontext在前一个查询之后运行的第二个查询,然后查询在t3停止扩展!即使对象id明显存在,该对象也为null.数据存在!所以这里有一些奇怪的东西.注意:我使用的是singleton objectcontext工厂类,因此每个页面都会实例化自己的对象上下文,以用于执行CRUD操作.
我的 Web 应用程序中有 6 个 WCF Web 服务。
在访问我的 MVC3 站点上的任何页面时,我可能会调用最多 4 个左右的 WCF 服务。
在我的实时环境中(就像在我的所有环境中一样),我将所有 Web 服务托管在同一台计算机上(每个前端服务器都有这些服务)。
我的问题是,我正在处理的网站运行速度非常慢,作为网站性能改进的一部分,我希望减少对这些各种 WCF 服务的所有这些 http 请求的开销。
我的问题是,是否可以以“非 http-overheady”的方式调用这些 Web 服务,因为它们无论如何都位于同一台计算机上?
我目前有一个WCF数据服务www.mywebsite.com.这是一个基本服务,如下所示:
namespace MyWeb
{
[JSONPSupportBehavior]
public class MyDataService : DataService<MyEntities>
{
public static void InitializeService(IDataServiceConfiguration config)
{
config.UseVerboseErrors = true;
config.SetEntitySetAccessRule("Entities", EntitySetRights.AllRead);
ServiceOperationRights.All);
}
}
}
Run Code Online (Sandbox Code Playgroud)
目前,我们有野外客户通过发布ajax调用来发出请求,例如:
$.ajax({
url: serverAddress + "MyDataService.svc/Entities?$top=20&$filter=IsConfirmed%20eq%20null&$format=json&$callback=?",
headers: {
version: "1.0",
platform: "a platform"
},
timeout: 12000,
dataType: 'jsonp',
cache: false,
context: document.body
})
Run Code Online (Sandbox Code Playgroud)
这按预期工作,返回包含Entities表中所需对象的javascript对象.
但是,我们希望在服务器端添加一些智能,以限制从此查询返回的结果.为此,我尝试在上述MyDataService类中实现Query Interceptor :
[QueryInterceptor("Entities")]
public IQueryable<Entity> OnQueryFares(IQueryable<Entity> query)
{
return from e in query
where DataCheck(e)
select e;
}
Run Code Online (Sandbox Code Playgroud)
目标逻辑是服务现在只返回DataCheck(e)评估为true的表条目.此功能似乎有效.但是,在使用客户端进行测试时,我收到以下错误:
Web Console(4448): Uncaught SyntaxError: …Run Code Online (Sandbox Code Playgroud) 我在 Asp.net MVC 上有一个简单的 Web 应用程序。我创建了一个 WFC 服务,以便我可以将数据发送到我的 Windows 8.1 应用程序,但是我的新功能没有显示在我的客户端中。
这是我的 WFC 代码:
[DataContract]
public class Service1 : IService1
{
ApplicationDbContext _db=new ApplicationDbContext();
public string GetData(int value)
{
return string.Format("You entered: {0}", value);
}
public WtFImages.Models.Images GetDataL(int value)
{
var User = _db.Image.Local.FirstOrDefault(c => c.Id == value);
return User;
}
public List<WtFImages.Models.Images> GetDataAll(int value)
{
var GetAllPublic = _db.Image.Local.ToList();
return (GetAllPublic);
}
public IList<WtFImages.Models.Images> ZGetDataAll(int value)
{
var GetAllPublic = _db.Image.Local.ToList();
return (GetAllPublic);
}
public CompositeType GetDataUsingDataContract(CompositeType composite)
{ …Run Code Online (Sandbox Code Playgroud) 我有一个.NET应用程序(不是IIS)公开的ADO.NET数据服务,它由.NET客户端应用程序使用.对此数据服务的某些调用会返回大量数据.
我想在线上压缩XML数据以减少有效负载并提高性能.这可能吗?
我正在玩Netflix odata服务,以更好地了解如何使用odata数据.
在VS 2010中,我添加了对NetFlix odata服务的服务引用.然后我写了这个代码,它只返回一些数据.
var cat = new NetflixCatalog(new Uri("http://odata.netflix.com/v1/Catalog/"));
var x = from t in cat.Titles
where t.ReleaseYear == 2009
select t;
foreach (Title title in x)
{
ProcessTitle(title);
}
Run Code Online (Sandbox Code Playgroud)
我查看了为调用生成的uri并在浏览器中运行它.它返回的原子进给最后有这个元素
<link rel="next" href="http://odata.netflix.com:20000/v1/Catalog/Titles()/?$filter=ReleaseYear%20eq%202009&$orderby=AverageRating%20desc&$skiptoken=3.9D,'BVqRa'" />
Run Code Online (Sandbox Code Playgroud)
这是一个将检索下一组数据的链接(由Netflix完成的分页).我的问题是如何让我的代码访问下一批数据和下一批数据?
我有一个远程wcf服务,我通过WSHttpBinding连接它.如果我使用空服务构造函数,这意味着它将从app.config获取所有配置,一切正常,(我的意思是MyService s = new MyService()).现在我想以编程方式配置wcf.这很简单,直到我到达身份验证问题,这很难做到.这是我使用的app.config,你可以看到我的安全配置.
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="SecuredEndPoint" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false"
transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="true" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://MyWcfService.svc"
binding="wsHttpBinding" bindingConfiguration="SecuredEndPoint"
contract="ServiceReference1.IMyService" name="SecuredEndPoint">
<identity>
<certificate encodedValue="*******************************************************************" />
</identity>
</endpoint>
</client>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud) 我没有意识到URI http://services.odata.org/OData/OData.svc/Categories(1)/Products和http://services.odata.org/OData/OData.svc/Categories(1)/$links/Products.之间有什么区别.在http://www.odata.org/documentation/uri-conventions/#AddressingLinksBetweenEntries文档说明不够清楚.
c# ×5
wcf ×4
odata ×3
.net ×2
ado.net ×1
asp.net ×1
asp.net-mvc ×1
gzip ×1
jsonp ×1
linq ×1
netflix ×1
wcf-binding ×1
wcf-security ×1