John-acme's Profile User Rating: -----

Reputation: 6 Worker
Group:
Active Members
Active Posts:
84 (0.05 per day)
Joined:
08-February 11
Profile Views:
2,976
Last Active:
User is offline Yesterday, 02:23 AM
Currently:
Offline

Previous Fields

Country:
ID
OS Preference:
Windows
Favorite Browser:
Who Cares
Favorite Processor:
Who Cares
Favorite Gaming Platform:
Who Cares
Your Car:
Who Cares
Dream Kudos:
0

Latest Visitors

Icon   John-acme has not set their status

Posts I've Made

  1. In Topic: Domain Model and Entity Framework

    Posted 27 Jun 2015

    RudiVisser : On my way testing further before arrive at 3 layer separation. I encounter a problem, I create a UI project. My Ui project only contain text filed to show StandardID and StandardName and a Button to Load the field.

    I connect UI project and my model base on Service Reference. So inside project that contain my Student class and Standard class I add web service (asmx) file. Inside the web service file I just add get method like below
    [WebMethod]
    public Standard GetStandardByID(int id) {
    	SchoolContext scontext = new SchoolContext();
    	Standard std = scontext.Standards.Where(stan => stan.StandardId == id)/*.Select(t => new {
    		StandardId = t.StandardId,
    		StandardName = t.StandardName
    	})*/.SingleOrDefault();
    	
    	return std;
    }
    
    

    But In my Standard class, the properties of Students return ICollection<>, instead concrete object List<>
    public ICollection<Student> Students { get; set; } //I use this instead of following line
    //public List<Student> Students { get; set; } 
    
    

    And I get error when add the service reference to UI project.
    the error is ::

    Quote

    Request format is unrecognized for URL unexpectedly ending in '/_vti_bin/ListData.svc/$metadata'.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.InvalidOperationException: Request format is unrecognized for URL unexpectedly ending in '/_vti_bin/ListData.svc/$metadata'.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:


    [InvalidOperationException: Request format is unrecognized for URL unexpectedly ending in '/_vti_bin/ListData.svc/$metadata'.]
    System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type type, HttpContext context, HttpRequest request, HttpResponse response) +489329
    System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext context, String verb, String url, String filePath) +212
    System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated) +47
    System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +346
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155


    When I changed back to use List<> then all was fine my UI able to show standardID and standardName.
  2. In Topic: Domain Model and Entity Framework

    Posted 26 Jun 2015

    Ah.. as RudiVisser suggested, I run debug and i found that Standard property in my result is null. then I try to change the query for result become
    Student result = (from stud in context.Students
    							  join stan in context.Standards
    							  on stud.StandardKey equals stan.StandardId
    							  where stud.StudentID == 90002
    							  select stud).SingleOrDefault();
    
    

    and the result still null, How to select Student with Standard included in?
    for the relationship on modelBuilder, I follow this tutorial EF Tutorial. I think their code is not wrong.

    Am I miss something?

    Updated :
    I try to change the result into this :
    Student result = context.Students.Include(s => s.Standard).Where(s => s.StudentID == 90002).SingleOrDefault();
    
    

    And the result is success. the ToString() method is invoked. Now it is clear that POCO in Code-First approach can be used can have behavior and use for other things.

    ===========
    Now still on similar problem. Above test is conducted on same project.
    I want to try to follow best practice of 3 layer structure. But for now let's discuss 2 layers which are BusinessLayer and DataAccessLayer. Each those layer will be one project, so total 3 project for 3 layer. As per theory, upper layer may depend on lower layer but not vice versa (or circular dependency occur).

    I plan to divide My Domain Object and the EF. Domain Object on BusinessLayer and EF(DbContext-derived class and all mapping syntax) stay on DataAccessLayer. Problem is now EF cannot recognize any of my DomainObject (my POCO). How should I done this? I tried partial class, but it was failed. DataAccessLayer cannot recognize any class from BusinessLayer. How should I do the mapping?
  3. In Topic: Combine same functionality services into one

    Posted 16 Jun 2015

    Skydiver: Well, it is not I married to Entity Framework. I would love to switch if there are better alternative at hand. And as for now, Entity Framework looks like (maybe) easier to put my hand on rather than ADO.NET, (at least) until before I post this question.

    baavgai:

    Quote

    Once I had a working API, I came to the conclusion that EF was getting in the way

    I do not understand in what way EF getting in the way. Did you mean the EF getting in the way same as in my case?

    Quote

    Using plain old SQL, I got a focused library with almost no dependencies. Warning: putting EF in a library is so horribly cumbersome as to be pointless

    I do not understand what you mean 'library' is and 'no dependencies' are, would you mind to give more concrete example? And mind if I have a glance on your code?(maybe I can also get something new by reading your code, I want to see if yours and mines have similarity). Thanks

    After I looking around for some time, looks like there are no way to put some abstraction layer over every each entities generated from my database model. Did you agree on this? And also, database and my code inevitably will have high coupling.

    Curtis Rutland: Thanks for your suggestion. I have a flash view on dapper, it is appealing. I would love to learn more.Thanks
  4. In Topic: Object Referred Properties (Best Practice Q)

    Posted 12 Jun 2015

    I see, so second approach is better. Thanks to both of you.^.^

    Skydiver: I would like to explore more about your suggestion (about ID should be hidden) and about object databases. I have search in Google 'object databases' and what it was showed up is DBMS like Virtuos or others where as I use SQL Server. I do not know SQL Server is Object Database or Relational Database. But What I got is what you mean is not the software but the approach in programming, object database approach. I never know this approach, as I am being taught that each row in database's table is represented by an object in programming. I would like to ask few links or sources that explain object database approach, if you do not mind. Thanks
  5. In Topic: Relationships Design Pattern

    Posted 12 Jun 2015

    Is not the way how programmer write code for objects to relate each other is a design pattern? Am I wrong in getting understand of what is design pattern? (As per your answer, yes of course I am wrong. I am glad to know that what I know is not what I think I know)

    Anyway if above is not a pattern (then forget about pattern) then still my question is still the same, are there any alternative for object to communicate with other object beside put every objects reference inside an object?

    Well, Model and View above is just a way to show how I usually make one object communicate with other object. I may change the name become ClassA and ClassB or ClassX and ClassY. Still back to topic, as I see, If I keep using same way as above, when I do add/change how data stored in Model then I must adjust how View process those data to present. If the whole program is complicated then many changes can make new bug or unwanted behavior. I do not want that, so I am seeking better way to code. And I do not know what must I search in Google to get what I want to know.

    Thanks replying.

My Information

Member Title:
D.I.C Head
Age:
22 years old
Birthday:
October 27, 1992
Gender:
Location:
Medan, Indonesia
Interests:
Programming, Books(Financial and Business)
Full Name:
Johnson
Programming Languages:
Java (learning)

Contact Information

E-mail:
Click here to e-mail me
Facebook:
http://www.facebook.com/profile.php?id=1550517916

Friends

John-acme hasn't added any friends yet.

Comments

John-acme has no profile comments yet. Why not say hello?