Comments (6)
Unfortunately, this infusionsoft API is one hell of a moving target.
Likely the best option is to apply a change property name refactoring to the property.
I accept pull requests. ;)
If you can't get to it, let me know and I'll do it tomorrow afternoon.
Cheers,
Chris
from infusionsoft.net.
Chris,
Thanks for the quick response. I had abandoned using another library because it had been error prone and I ended up writing my own wrapper as needed but it was never complete. I found yours on NuGet and decided to give it a try for this project. As it is, I don't have much time to find and fix this issue. For now, I am using the standard method signature instead of the LINQ expressions just so I can move forward. If I get time, I'll take a look and see if I can push a fix unless you beat me to it.
Thanks again,
Richard
On Jan 22, 2014, at 1:46 AM, Chris Martin [email protected] wrote:
Unfortunately, this infusionsoft API is one hell of a moving target.
Likely the best option is to apply a change property name refactoring to the property.
I accept pull requests. ;)
If you can't get to it, let me know and I'll do it tomorrow afternoon.
Cheers,
Chrisโ
Reply to this email directly or view it on GitHub.
from infusionsoft.net.
There is a problem with the way Infusionsoft designed the Company table. Instead of Name
or CompanyName
, they called the name field Company
. C# doesn't allow property names to be the same as their enclosing type though. So the generated class creates an aliasโCompanyName
โand tells XmlRpc to map it to the Company
field. The definition looks like this:
[XmlRpcMember("Company")]
[Access(Access.Edit | Access.Delete | Access.Add | Access.Read)]
public string CompanyName { get; set; }
Ultimately, the query translator needs to check if the XmlRpcMember attribute name matches the property name. If they don't match, it needs to use the attribute value when serializing the query.
Unfortunately, even using the untyped Query method, I get zero results for a query that should have 200+. The only way I can query companies right now is to fetch them all & do my LINQ filtering on the client side. Here's a wildcard query (name starts with A) that I think should work, but either I'm missing something or something outside my control is borked:
var queryData = new XmlRpcStruct() { { "Company", "A%" } };
var cs = client.DataService.Query(
table: "Company",
limit: 1000,
page: 1,
queryData: queryData,
selectedFields: new[] {"CompanyID", "Company", "State", "PostalCode", "Country"});
from infusionsoft.net.
I have a fix for this. The query builder just needs a dictionary of property names that don't match Infusionsoft's actual column names. Here's the patch that got it working for me (I can do a normal query on CompanyName now; this should also enable LINQ query expressions to address any field that's not named the same as the table column). First, add the following extension class in the InfusionSoft namespace:
internal static class QueryBuilderExtensions
{
private static Dictionary<Type, Dictionary<string, string>> _columnNames;
private static Dictionary<Type, Dictionary<string, string>> ColumnNames
{
get
{
return _columnNames ?? (_columnNames = new Dictionary<Type, Dictionary<string, string>>());
}
}
public static string GetColumnName<T>(this IQueryBuilder<T> builder, string propertyName) where T : ITable
{
if (!ColumnNames.ContainsKey(typeof(T)))
{
ColumnNames[typeof(T)] = new Dictionary<string, string>();
typeof(T).GetProperties()
.Where(p => !p.Name.Equals("CustomFields") && !p.Name.EndsWith("Comparer"))
.ToList()
.ForEach(p =>
{
var attributes = p.GetCustomAttributes(typeof(XmlRpcMemberAttribute), false);
if (!attributes.Any())
return;
var attribute = attributes.Cast<XmlRpcMemberAttribute>().First();
if (!String.IsNullOrEmpty(attribute.Member) && attribute.Member != p.Name)
{
ColumnNames[typeof(T)].Add(p.Name, attribute.Member);
}
});
}
return ColumnNames[typeof(T)].ContainsKey(propertyName) ? _columnNames[typeof(T)][propertyName] : propertyName;
}
}
Then change the main overload of QueryBuilder.Add as such:
public IQueryBuilder<T> Add<TV>(Expression<Func<T, TV>> expression, TV value, ValuePosition valuePosition)
{
string name = Express.PropertyWithLambda(expression).Name;
name = this.GetColumnName(name);
_dictionary.Add(name, BuildPositionalValue(valuePosition, value));
return this;
}
from infusionsoft.net.
Excellent. Thanks for the effort.
If you issue a pull request, I'll merge it in.
from infusionsoft.net.
Done, thanks! Let me know if everything's satisfactory.
from infusionsoft.net.
Related Issues (20)
- OAuth HOT 2
- Using DataService.Query<Table>(page, queryBuilder,fieldSelection) with dates in queryBuilder returns no results. HOT 4
- DataService.Count HOT 3
- RecurringOrderWithContact field HTMLSignature preventing Query<RecurringOrderWithContact>(..)
- Issue calling FileService.UploadFile HOT 8
- ContactService.AddToCampaign {"Server returned a fault exception: [6] [Loading]Error loading follow-up sequence"} HOT 1
- Create Tag/ Get all Tag / Get Tag by Name HOT 2
- .Net Helper Library for REST api support
- Question: What is the "application" value expected? HOT 1
- Error on .Update = A parameter is of, or contains an instance of, type System.Collections.Generic.Dictionary... which cannot be mapped to an XML-RPC type HOT 3
- Unable to get the InfusionSoft project to work in VS2013 HOT 1
- InfusionSoftException when using FindByEmail and IncludeAll
- Hello
- Cannot retrieve custom fields with api call. HOT 1
- Query by Ids
- API ChargeInvoice response contains implicit string value where integer expected HOT 3
- Doesn't work with .net core HOT 2
- New .NET Infusionsoft Client
- TLS 1.2 HOT 9
- How can i create a custom field for Contact? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from infusionsoft.net.