Created
August 30, 2012 12:55
-
-
Save jasondentler/3527949 to your computer and use it in GitHub Desktop.
Floor plan VM index issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var doc = { | |
"Id": "a04d38cd-ab02-41cd-ac67-2070f214daf5", | |
"MarketId": "778ac624-2337-4c6c-a741-20175aa694e7", | |
"Name": "Katy", | |
"StateAbbreviation": "TX" | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var doc = { | |
"Id": "7fef7338-76a7-4afd-b13d-d5b80b083dc6", | |
"CityId": "a04d38cd-ab02-41cd-ac67-2070f214daf5", | |
"Name": "Cinco Ranch", | |
"Status": "CloseOut" | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GET /databases/Website/indexes/FloorPlanVMIndex?query=__document_id%253AFloorPlanVMs%252F9fdb4a75-96a8-4c4f-b7ab-bd348d98fd36&start=0&pageSize=2&aggregation=None HTTP/1.1 | |
Content-Type: application/json; charset=utf-8 | |
Raven-Client-Version: 1.2.0.0 | |
Host: localhost:8080 | |
HTTP/1.1 200 OK | |
Transfer-Encoding: chunked | |
Content-Type: application/json; charset=utf-8 | |
Expires: Sat, 01 Jan 2000 00:00:00 GMT | |
ETag: 684ee109-ce9e-43f0-a22b-7d96cec27064 | |
Server: Microsoft-HTTPAPI/2.0 | |
Raven-Server-Build: 888 | |
Date: Thu, 30 Aug 2012 13:03:56 GMT | |
129 | |
{"Results":[],"Includes":[],"IsStale":false,"IndexTimestamp":"2012-08-29T15:33:42.7900000","TotalResults":0,"SkippedResults":0,"IndexName":"FloorPlanVMIndex","IndexEtag":"00000000-0000-3b00-0000-00000000000a","ResultEtag":"684ee109-ce9e-43f0-a22b-7d96cec27064","NonAuthoritativeInformation":false} | |
0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var doc = { | |
"Id": "9fdb4a75-96a8-4c4f-b7ab-bd348d98fd36", | |
"CommunityId": "7fef7338-76a7-4afd-b13d-d5b80b083dc6", | |
"PlanMasterId": "0e64cc70-fc72-4ade-a059-496502b2dc15", | |
"BasePrice": 350000, | |
"Elevations": [ | |
"A", | |
"B" | |
], | |
"SqFeetOverride": { | |
"Min": 1300, | |
"Max": 4000 | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FloorPlanVMIndex : AbstractIndexCreationTask<FloorPlan, FloorPlan> | |
{ | |
public FloorPlanVMIndex() | |
{ | |
Map = floorPlans => from floorPlan in floorPlans | |
select new {floorPlan.Id}; | |
TransformResults = | |
(database, floorPlans) => from floorPlan in floorPlans | |
let community = database.Load<Community>("communities/" + floorPlan.CommunityId) | |
let planMaster = database.Load<PlanMaster>("planMasters/" + floorPlan.PlanMasterId) | |
let city = database.Load<City>("cities/" + community.CityId) | |
let market = database.Load<Market>("markets/" + city.MarketId) | |
select new | |
{ | |
Id = Guid.Parse(floorPlan.Id.ToString().Split('/')[1]), | |
BasePrice = floorPlan.BasePrice, | |
CityName = city.Name, | |
CommunityName = community.Name, | |
CommunityStatus = community.Status, | |
MarketName = market.Name, | |
Name = planMaster.Name, | |
PlanNumber = planMaster.PlanNumber, | |
SqFeet = floorPlan.SqFeetOverride ?? planMaster.SqFeet | |
}; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var doc = { | |
"Id": "778ac624-2337-4c6c-a741-20175aa694e7", | |
"Name": "Houston", | |
"StateAbbreviation": "TX" | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var doc = { | |
"Id": "0e64cc70-fc72-4ade-a059-496502b2dc15", | |
"MarketId": "778ac624-2337-4c6c-a741-20175aa694e7", | |
"PlanNumber": "1145", | |
"Name": "Beezer", | |
"SqFeet": { | |
"Min": 1200, | |
"Max": 5000 | |
}, | |
"Elevations": [ | |
"A", | |
"B", | |
"C" | |
] | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return _session.Query<FloorPlan, FloorPlanVMIndex>() | |
.Where(fp => fp.Id == id) | |
.As<FloorPlanVM>() | |
.SingleOrDefault(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment