Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullRefenceException at GetResultSets. #403

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zhdusurfin
Copy link

NullRefenceException fixed at ExecuteResultSet<T> thowing in following example.

Object model:

public class Document
{
  [MapField("Id")]
  public long Id { get; set; }

  [MapField("DocumentType")]
  public string DocType { get; set; }

  [MapField("File")]
  public DocumentContent File { get; set; }

  [MapField("KeyValue")]
  public List<KeyValue> KeyValue { get; set; } = new List<KeyValue>();
}
public class DocumentContent
{
  public long DocumentId { get; set; }

  [MapField("Content")]
  public byte[] Content { get; set; }

  public SubContent Sub { get; set; }
}

public class SubContent
{
  public long ContentId { get; set; }
  public long Val { get; set; }
}

Using SQL procedure to return data.

CREATE procedure [dbo].[GetDocument]
@id bigint
as
begin
	set nocount on
	
	select * from Document where Id = @id
	select * from Content where DocumentId = @id
	(select @id as ContentId , @id as Val) -- sub content
	
	
	select * from KeyValue where DocumentId = @id
end

In accessor we have a method retutning Document object

var manager = GetDbManager();

var set = manager
  .SetSpCommand("GetDocument", manager.Parameter(ParameterDirection.Input, "@id", id))
  .ExecuteResultSet<Document>(
    new MapNextResult(typeof(DocumentContent), new MapIndex(new[] { "DocumentId" }), new MapIndex(new[] { "Id" }), "File",
    new MapNextResult(typeof(SubContent), new MapIndex(new[] { "ContentId" }), new MapIndex(new[] { "DocumentId" }), "Sub")),
    new MapNextResult(typeof(KeyValue), new MapIndex(new[] { "DocumentId" }), new MapIndex(new[] { "Id" }), "KeyValue"));

return (Document)set[0].List[0];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant