English 中文(简体)
我如何通过亚慢性物体从合并表格中获取数据?
原标题:How do I return data from joined tables through subsonic s objects?

采用代号3的积极记录,我实际上希望这样做:

  select * from foo
   left outer join bar on bar.Id = foo.barId
where foo.someProperty = 2

我写了一份储存程序,以收集数据,但分站只制造了从烟.和酒类中排的物体。

将数据退回到单一物体的最佳方式是什么,因此我只能对其加以约束。 理想的情况是,我想把它列入一个名单和编号;但没有写上我自己的类别,那么现在就看不出分位。

最佳回答

这里有两种选择。

你可以形成一种数据库观点,使你加入,并且为您提供分站式数据,然后,你们的选择就象从任何其他表格中选择。

或者,如果你使用国邮局,你可以使用国邮局的表述方式加入匿名或动态类型(如果你使用国邮局)。 4) 例如:

public List<dynamic> LoadData(int id)
{
  var data = from f in db.Foo
             from b in db.Bar.Where(x => x.Id == f.BarId).DefaultIfEmpty()
             where f.SomeProperty == id
             select new
             {
               SomeProperty = f.Something,
               AnotherProperty = b.SomethingElse
             };
  return data.Cast<dynamic>().ToList();
}

当然,另一种选择是采用上文提到的Linq语,但界定了你自己的类别以掌握所交数据并选择数据。

public class MyData
{
  public string SomeProperty { get; set; }
  public string AnotherProperty { get; set; }
}

public List<MyData> LoadData(int id)
{
  var data = from f in db.Foo
             from b in db.Bar.Where(x => x.Id == f.BarId).DefaultIfEmpty()
             where f.SomeProperty == id
             select new MyData()
             {
               SomeProperty = f.Something,
               AnotherProperty = b.SomethingElse
             };
  return data.ToList();
}
问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签