mvc, class library

I have the codes below
1. RetrieveData is working fine., but now I want to assign class library value in a loop.
Basically, I have wcf call to get the list of name which is exactly same as class library property name - see newretrievedata
Is it possible to do that?

On another side of class library in c#, i already have all of the property/object in class library.


     
  public JsonResult RetrieveData(string ID)
        {
            Domain.Lead l = new Domain.Lead();
            l.firstname = "John";
            l.lastname = "Smith";
            return Json(l, JsonRequestBehavior.AllowGet);
        }

 
        public JsonResult newRetrieveData(string ID)
        {
            Domain.Lead l = new Domain.Lead();


            foreach (KeyValuePair<string, string> i in Helper.DynamicsCRM.GetAllLeadInfoByMetaData3("a51ec467-7255-e811-81153863bb3c4538"))
            {               
                //Response.Write(i.Key + " >> " + i.Value + "<br>"); Key has firstname, and lastname, etc.
            	l.i.Key = i.Value;
            }
            return Json(l, JsonRequestBehavior.AllowGet);
        }

Open in new window

LVL 1
ITsolutionWizardAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ste5anSenior DeveloperCommented:
Please rephrase your question.

but now I want to assign class library value in a loop.
There is no such thing, like a "class library value"..

To some extent, you may call it is so, if you do manual assembly/DLL loading, but only when accepting improper naming of variables.
ITsolutionWizardAuthor Commented:
So u can help or not?
ste5anSenior DeveloperCommented:
Sure: rephrase.
Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

ITsolutionWizardAuthor Commented:
Assign value meaning like below

Person.firstname = "john"

Normally, I assign above and now I hope to get the property name and value by reading wcf that I created
ste5anSenior DeveloperCommented:
Sorry for nitpicking, but WCF must use XML, not JSON. And by rephrase I mean to describe what you are doing, where it is failing. It also means to explain you context. You haven't posted enough information nor consistent information so far.

E.g. what is your solution/project architecture? What stack(s) do you use?
If I look at your sample fragments: Do you develop a REST web service? Do you use ASP.NET Web API?

Your sample seem to define two endpoints: RetrieveData() and newRetrieveData(). The first returns a static object, while the second returns some arbitrary data.

Problem 1: Big problem, so sad. The naming is bad. RetrieveData and newRetrieveData is only a generic description. API names should be specific, concise and exact. RetrieveData should be named at least RetrieveLead. newRetrieveData (here I need to guess a little bit) should be named RetrieveLeadInformation.

Problem 2: Both methods pretend to be dynamic. But they return either a static value or some arbitrary data. Thus this API is currently lying.

Problem 3: Is a little bit more sophisticated, cause it's about architecture. Layers and abstraction. The web service is normally a service façade of the business logic. Which sits on top of the data access layer. In the data access layer we normally find methods like  Helper.DynamicsCRM.GetAllLeadInfoByMetaData3. But this is never a "Helper". Nor should it return untyped data. KeyValuePair<string, string> is a generic and does not transmit sematic information. The method Helper.DynamicsCRM.GetAllLeadInfoByMetaData3 is normally part of the repository pattern. Furthermore how is your data transfer object (DTO, POCO) Domain.Lead defined?
Based on the given facts the LeadRepository should have the methods RetrieveLead(predicates) and RetrieveLeads(predicates). And depending on the use-case the symmetric Create, Update and Delete methods also to complete the CRUD paradigm here. The Lead class should have a property Metadata.

p.s. Consider using unit tests with a test driven approach to avoid that ("hope").
ITsolutionWizardAuthor Commented:
Please don't worry my wcf. If you can help, focus on my code only. Thank you for your helps and time
ste5anSenior DeveloperCommented:
Okay, the hard way:

If you can help, focus on my code only
You've posted only fragments.. these fragments don't contain any error. But bad coding style and bad architectural approaches.

And the only sentence I understood in your OP:
Is it possible to do that?
Yes, cause it is a rhetorical question. Is it advisable? No. So my post above..

And for the rest of your post(s): They are hard to understand, you don't use common terms. Instead you created your own. You posted only code fragments instead of a concise and complete example. In short: you don't provided the needed information nor context. I've asked twice to do so. HHCIB?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET MVC

From novice to tech pro — start learning today.