|
I have 2 identical models:
public class CredentialAPIModel
{
public string UserName { get; set; }
public string Password { get; set; }
}
and
public class CredentialEntity
{
public string UserName { get; set; }
public string Password { get; set; }
}
and my mappings
Mapper.CreateMap<CredentialEntity, CredentialAPIModel>();
Mapper.CreateMap<CredentialAPIModel, CredentialEntity>();
And this is where it fails:
public LoginAPIResponse Login(CredentialAPIModel credentials)
{
CredentialEntity credentialEntity = Mapper.Map<CredentialAPIModel, CredentialEntity>(credentials);
LoginResponse appSecurityResponse = BO.Login(credentialEntity);
.
.
.
}
I get this:
Missing type map configuration or unsupported mapping.
Mapping types:
CredentialAPIModel -> CredentialEntity
FMG.WebServiceAPI.Models.AppSecurity.Models.CredentialAPIModel -> FMG.Entities.AppSecurity.Entities.CredentialEntity
Destination path:
CredentialEntity
Source value:
FMG.WebServiceAPI.Models.AppSecurity.Models.CredentialAPIModel
Mapper.AssertConfigurationIsValid() does not find any errors.
Anyone see what's wrong here?
Thanks
If it's not broken, fix it until it is
modified 28-Oct-13 21:37pm.
|
|
|
|
|
Are you sure, your method where you create mapping is being called ?
just for testing, try to create mapping in Login method before you map as shown below :
public LoginAPIResponse Login(CredentialAPIModel credentials)
{
Mapper.CreateMap<CredentialEntity, CredentialAPIModel>();
Mapper.CreateMap<CredentialAPIModel, CredentialEntity>();
CredentialEntity credentialEntity = Mapper.Map<CredentialAPIModel, CredentialEntity>(credentials);
LoginResponse appSecurityResponse = BO.Login(credentialEntity);
}
Regards,
CodeBlack
|
|
|
|
|
Good day everyone. I am developing an application that uses Microsoft Access as database. I want that during installation, the database file should be installed in the C:\Users\<username>\Documents folder. Please, how do I go about this. Also, how can I use this path in my application when operating on the database. Any help will be appreciated. Thanks
|
|
|
|
|
string documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Thanks alot @Richard. But I dont quite get how to include the above code in connecting to my database.
My code looks like this
string dbconnect = @"Provider = Microsoft.Jet.OleDB.4.0; Data Source = C:\Users\elfico\Documents\accounts.mdb";
Please, any help will be appreciated.
|
|
|
|
|
The setup program is likely executed by a different user. Hence it is not easy to determine the Documents folder of a specific user. If the databse could be shared among all users of that computer, I'd suggest to use a folder below ProgramData instead.
|
|
|
|
|
Thanks a lot @Bernard. I had tried to have the database file install in the Program Files and i found out that I could only read from the database, but cannot write to it. Will using the Program Data folder enable me to read/write my database. Your reply is highly appreciated.
|
|
|
|
|
Exactly that's the point. ProgramFiles is "read-only" for users, for security reasons. PrgramData (which corresponds to XP's C:\Documents and Settings\All Users) is the place where all users of a computer can access the files with read and write access.
Normally, you'll create a folder with your company name there, and below that a folder for your specific program. I.e. C:\ProgramData\YourCompany\YourFirstProgram. Use the Environment.GetSpecialFolder function, as suggested by Richard.
|
|
|
|
|
Thank you very much. Your reply was very helpful. Talking about the other method mentioned by Richard, I need a little clarification on how to include it in my code. Am a bit of a newbie. Thanks.
|
|
|
|
|
I am developing a .net windows application to fetch HTML from a particular web page. I am using WebBrowser control to launch the web page and trying to fetch the HTML source. But, what i am getting is HTML from View Source. There is difference between HTML source in View Source and in Developer Tool. please help me in fetching the HTML source from Developer Tool.
|
|
|
|
|
It's not possible to answer your question. What do you mean by "Developer Tool"?? WHat do you mean by "getting the source from the developer tool" as opposed to the HTML source the brwoser gets? How do you know the difference?? Is this a website that you control and have the source for??
|
|
|
|
|
I mean in IE if I click on f12 I get a developer tool which will have a html code. When right click on a webpage and select view source I can see the html code.
There is difference between view source html and what I see in developer tool html code.
Below is the code for accessing view source html code:
HtmlElementCollection objHtmlElementCollection = null;
HtmlDocument objHtmlDocument = webBrowser1.Document;
similarly I want to access developer tool's html code.
Please help..
|
|
|
|
|
There is no "developer tools source". What you're seeing is a debugger analysis of the same source you see in "View Source". There is no different "source" you can possibly get from the browser.
|
|
|
|
|
The code is different in view source and developer tool source.
I have a scenario where a button is being displayed as in view source, whereas in developer tool, it is displayed as . Also, when i tried accessing a web page with frames, in View Source, i could not able to see the control tags appearing inside the frame, whereas i could see those in developer tools.
|
|
|
|
|
|
Yes. Can I access this interpreted html in my code?
|
|
|
|
|
No, as we have repeatedly told you, what you get from the website is the exact HTML. There are classes and methods in .NET that will help you manipulate the content but you still need to write the code to suit your requirements.
Veni, vidi, abiit domum
|
|
|
|
|
No. It's not exposed by Internet Explorer. You'd have to write you own debugger/interpreter to get the same data and all you have to work with is the exact same source you see in "View Source".
|
|
|
|
|
Thank you.
Do you have any idea why is shown as in view source? Some pages I see as in view source but in some other pages it is different.
Please help me.
|
|
|
|
|
That's because <button> is shorthand for an <input> with a type of "button".
|
|
|
|
|
I am trying to write a small code to find the possible combinations from a list of integer values which when added is equal to the input value or somewhat nearing.
List<int> comb = new List<comb>() { 618, 350, 308, 300, 250, 232, 200, 128 };
The above list contains the integer values from which the proper combination has to be generated
The combination should have least number of values i.e., greatest number has to used most
Example:
If Input from User [Value = 2386]
Combination 1 = 618 + 350 + 308 + 300 + 250 + 232 + 200 + 128
Combination 2 = 618 + 618 + 618 + 300 + 232
I have used the below code, but have missed some logic.
public static void Main(string[] args)
{
//subtotal list
List<int> totals = new List<int>(new int[] { 618, 350, 308, 300, 250, 232, 200, 128 });
// get matches
List<int[]> results = KnapSack.MatchTotal(2682, totals);
// print results
foreach (var result in results)
{
Console.WriteLine(string.Join(",", result));
}
Console.WriteLine("Done.");
}
internal static List<int[]> MatchTotal(int theTotal, List<int> subTotals)
{
List<int[]> results = new List<int[]>();
while (subTotals.Contains(theTotal))
{
results.Add(new int[1] { theTotal });
subTotals.Remove(theTotal);
}
if (subTotals.Count == 0)
return results;
subTotals.Sort();
double mostNegativeNumber = subTotals[0];
if (mostNegativeNumber > 0)
mostNegativeNumber = 0;
if (mostNegativeNumber == 0)
subTotals.RemoveAll(d => d > theTotal);
for (int choose = 0; choose <= subTotals.Count; choose++)
{
IEnumerable<IEnumerable<int>> combos = Combination.Combinations(subTotals.AsEnumerable(), choose);
results.AddRange(from combo in combos where combo.Sum() == theTotal select combo.ToArray());
}
return results;
}
public static class Combination
{
public static IEnumerable<IEnumerable<T>> Combinations<T>(this IEnumerable<T> elements, int choose)
{
return choose == 0 ?
new[] { new T[0] } :
elements.SelectMany((element, i) =>
elements.Skip(i + 1).Combinations(choose - 1).Select(combo => (new[] { element }).Concat(combo)));
}
}
Is there any other way other than the above to get combinations
|
|
|
|
|
Simplest one for me was
List<int> comb = new List<int>() { 618, 350, 300, 250, 200, 128 };
List<int> output = new List<int>();
output = CalcLowestCombination(comb, 2386);
List<int> Test2 = CalcLowestCombination(comb, 1096);
private static List<int> CalcLowestCombination(List<int> comb, int ToAchieve)
{
List<int> output = new List<int>();
foreach (int value in comb)
{
while (value <= ToAchieve)
{
output.Add(value);
ToAchieve -= value;
}
}
return output;
}
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
The logic returns a combination but when output list is added, it does not return the input value. The Logic fails here.
|
|
|
|
|
There are some good articles on CP (for both C# and C++) on generating combinations, permutations, etc. : [^]. An interesting debate and brawl on StackOverFlow on various permutation generating algorithms here: [^].
While the permutations of a set of eight would be around 40k, the fact that your solution is going to consider multiple uses of any one item suggests to me you will have a vast "combinatorial" space to examine for a set of eight.
good luck, Bill
Google CEO, Erich Schmidt: "I keep asking for a product called Serendipity. This product would have access to everything ever written or recorded, know everything the user ever worked on and saved to his or her personal hard drive, and know a whole lot about the user's tastes, friends and predilections." 2004, USA Today interview
|
|
|
|
|
I don't have a solution, but looking at the exercise I imagine that you will probably need to use the %(mod) operator to determine what value you have left to calculate in your iterations.
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
|
|
|
|